diff --git a/kclvm/ast/src/ast.rs b/kclvm/ast/src/ast.rs index d205e8fb0..8b628761f 100644 --- a/kclvm/ast/src/ast.rs +++ b/kclvm/ast/src/ast.rs @@ -401,7 +401,7 @@ impl Module { /// A statement #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type")] pub enum Stmt { TypeAlias(TypeAliasStmt), Expr(ExprStmt), @@ -643,7 +643,7 @@ pub struct SchemaIndexSignature { pub struct SchemaAttr { pub doc: String, pub name: NodeRef, - pub op: Option, + pub op: Option, pub value: Option>, pub is_optional: bool, pub decorators: Vec>, @@ -670,7 +670,7 @@ pub struct RuleStmt { /// A expression #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type")] pub enum Expr { Identifier(Identifier), Unary(UnaryExpr), @@ -791,7 +791,7 @@ pub struct UnaryExpr { #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct BinaryExpr { pub left: NodeRef, - pub op: BinOrCmpOp, + pub op: BinOp, pub right: NodeRef, } @@ -1136,7 +1136,7 @@ pub struct Compare { /// """long string literal""" /// ``` #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type")] pub enum Literal { Number(NumberLit), String(StringLit), @@ -1200,7 +1200,7 @@ impl NumberBinarySuffix { } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type", content = "value")] pub enum NumberLitValue { Int(i64), Float(f64), @@ -1566,20 +1566,12 @@ impl CmpOp { /// BinOrCmpOp is the set of all binary and comparison operators in KCL. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type")] pub enum BinOrCmpOp { Bin(BinOp), Cmp(CmpOp), } -/// BinOrAugOp is the set of all binary and argument operators in KCL. -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] -pub enum BinOrAugOp { - Bin(BinOp), - Aug(AugOp), -} - /// ExprContext represents the location information of the AST node. /// The left side of the assignment symbol represents `Store`, /// and the right side represents `Load`. @@ -1591,7 +1583,7 @@ pub enum ExprContext { /// A expression #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type", content = "value")] pub enum Type { Any, Named(Identifier), @@ -1634,14 +1626,20 @@ pub struct UnionType { } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -#[serde(tag = "type", content = "data")] +#[serde(tag = "type", content = "value")] pub enum LiteralType { Bool(bool), - Int(i64, Option), // value + suffix + Int(IntLiteralType), // value + suffix Float(f64), Str(String), } +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct IntLiteralType { + pub value: i64, + pub suffix: Option, +} + impl ToString for Type { fn to_string(&self) -> String { fn to_str(typ: &Type, w: &mut String) { @@ -1697,7 +1695,7 @@ impl ToString for Type { w.push_str("False"); } } - LiteralType::Int(v, suffix) => { + LiteralType::Int(IntLiteralType { value: v, suffix }) => { if let Some(suffix) = suffix { w.push_str(&format!("{}{}", v, suffix.value())); } else { diff --git a/kclvm/ast/src/tests.rs b/kclvm/ast/src/tests.rs index c01922d1f..ebaa19797 100644 --- a/kclvm/ast/src/tests.rs +++ b/kclvm/ast/src/tests.rs @@ -81,7 +81,7 @@ fn get_dummy_assign_binary_ast() -> ast::Node { ))], value: Box::new(ast::Node::new( ast::Expr::Binary(ast::BinaryExpr { - op: ast::BinOrCmpOp::Bin(ast::BinOp::Add), + op: ast::BinOp::Add, left: Box::new(ast::Node::new( ast::Expr::Identifier(ast::Identifier { names: vec![Node::dummy_node(String::from("a"))], diff --git a/kclvm/ast_pretty/src/node.rs b/kclvm/ast_pretty/src/node.rs index a41b1ae97..a80aa4913 100644 --- a/kclvm/ast_pretty/src/node.rs +++ b/kclvm/ast_pretty/src/node.rs @@ -349,10 +349,7 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { self.write(": "); self.write(&schema_attr.ty.node.to_string()); if let Some(op) = &schema_attr.op { - let symbol = match op { - ast::BinOrAugOp::Bin(bin_op) => bin_op.symbol(), - ast::BinOrAugOp::Aug(aug_op) => aug_op.symbol(), - }; + let symbol = op.symbol(); self.write_space(); self.write(symbol); self.write_space(); @@ -382,10 +379,7 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { } fn walk_binary_expr(&mut self, binary_expr: &'ctx ast::BinaryExpr) -> Self::Result { - let symbol = match &binary_expr.op { - ast::BinOrCmpOp::Bin(bin_op) => bin_op.symbol(), - ast::BinOrCmpOp::Cmp(cmp_op) => cmp_op.symbol(), - }; + let symbol = binary_expr.op.symbol(); self.expr(&binary_expr.left); self.write_space(); self.write(symbol); diff --git a/kclvm/compiler/src/codegen/llvm/node.rs b/kclvm/compiler/src/codegen/llvm/node.rs index ef50b25b8..fcd32850e 100644 --- a/kclvm/compiler/src/codegen/llvm/node.rs +++ b/kclvm/compiler/src/codegen/llvm/node.rs @@ -1522,7 +1522,7 @@ impl<'ctx> TypedResultWalker<'ctx> for LLVMCodeGenContext<'ctx> { if let Some(op) = &schema_attr.op { match op { // Union - ast::BinOrAugOp::Aug(ast::AugOp::BitOr) => { + ast::AugOp::BitOr => { let org_value = self.build_call( &ApiFunc::kclvm_dict_get_value.name(), &[ @@ -1588,7 +1588,7 @@ impl<'ctx> TypedResultWalker<'ctx> for LLVMCodeGenContext<'ctx> { if let Some(op) = &schema_attr.op { match op { // Union - ast::BinOrAugOp::Aug(ast::AugOp::BitOr) => { + ast::AugOp::BitOr => { let org_value = self.build_call( &ApiFunc::kclvm_dict_get_value.name(), &[ @@ -1668,11 +1668,8 @@ impl<'ctx> TypedResultWalker<'ctx> for LLVMCodeGenContext<'ctx> { fn walk_binary_expr(&self, binary_expr: &'ctx ast::BinaryExpr) -> Self::Result { check_backtrack_stop!(self); - let is_logic_op = matches!( - binary_expr.op, - ast::BinOrCmpOp::Bin(ast::BinOp::And) | ast::BinOrCmpOp::Bin(ast::BinOp::Or) - ); - let is_membership_as_op = matches!(binary_expr.op, ast::BinOrCmpOp::Bin(ast::BinOp::As)); + let is_logic_op = matches!(binary_expr.op, ast::BinOp::And | ast::BinOp::Or); + let is_membership_as_op = matches!(binary_expr.op, ast::BinOp::As); if !is_logic_op { let left_value = self .walk_expr(&binary_expr.left) @@ -1690,50 +1687,25 @@ impl<'ctx> TypedResultWalker<'ctx> for LLVMCodeGenContext<'ctx> { .expect(kcl_error::COMPILE_ERROR_MSG) }; let value = match binary_expr.op { - ast::BinOrCmpOp::Bin(ast::BinOp::Add) => self.add(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::Sub) => self.sub(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::Mul) => self.mul(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::Div) => self.div(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::FloorDiv) => { - self.floor_div(left_value, right_value) - } - ast::BinOrCmpOp::Bin(ast::BinOp::Mod) => self.r#mod(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::Pow) => self.pow(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::LShift) => { - self.bit_lshift(left_value, right_value) - } - ast::BinOrCmpOp::Bin(ast::BinOp::RShift) => { - self.bit_rshift(left_value, right_value) - } - ast::BinOrCmpOp::Bin(ast::BinOp::BitAnd) => self.bit_and(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::BitOr) => self.bit_or(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::BitXor) => self.bit_xor(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::And) => self.logic_and(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::Or) => self.logic_or(left_value, right_value), - ast::BinOrCmpOp::Bin(ast::BinOp::As) => self.r#as(left_value, right_value), - ast::BinOrCmpOp::Cmp(ast::CmpOp::Eq) => self.cmp_equal_to(left_value, right_value), - ast::BinOrCmpOp::Cmp(ast::CmpOp::NotEq) => { - self.cmp_not_equal_to(left_value, right_value) - } - ast::BinOrCmpOp::Cmp(ast::CmpOp::Gt) => { - self.cmp_greater_than(left_value, right_value) - } - ast::BinOrCmpOp::Cmp(ast::CmpOp::GtE) => { - self.cmp_greater_than_or_equal(left_value, right_value) - } - ast::BinOrCmpOp::Cmp(ast::CmpOp::Lt) => self.cmp_less_than(left_value, right_value), - ast::BinOrCmpOp::Cmp(ast::CmpOp::LtE) => { - self.cmp_less_than_or_equal(left_value, right_value) - } - ast::BinOrCmpOp::Cmp(ast::CmpOp::Is) => self.is(left_value, right_value), - ast::BinOrCmpOp::Cmp(ast::CmpOp::IsNot) => self.is_not(left_value, right_value), - ast::BinOrCmpOp::Cmp(ast::CmpOp::Not) => self.is_not(left_value, right_value), - ast::BinOrCmpOp::Cmp(ast::CmpOp::NotIn) => self.not_in(left_value, right_value), - ast::BinOrCmpOp::Cmp(ast::CmpOp::In) => self.r#in(left_value, right_value), + ast::BinOp::Add => self.add(left_value, right_value), + ast::BinOp::Sub => self.sub(left_value, right_value), + ast::BinOp::Mul => self.mul(left_value, right_value), + ast::BinOp::Div => self.div(left_value, right_value), + ast::BinOp::FloorDiv => self.floor_div(left_value, right_value), + ast::BinOp::Mod => self.r#mod(left_value, right_value), + ast::BinOp::Pow => self.pow(left_value, right_value), + ast::BinOp::LShift => self.bit_lshift(left_value, right_value), + ast::BinOp::RShift => self.bit_rshift(left_value, right_value), + ast::BinOp::BitAnd => self.bit_and(left_value, right_value), + ast::BinOp::BitOr => self.bit_or(left_value, right_value), + ast::BinOp::BitXor => self.bit_xor(left_value, right_value), + ast::BinOp::And => self.logic_and(left_value, right_value), + ast::BinOp::Or => self.logic_or(left_value, right_value), + ast::BinOp::As => self.r#as(left_value, right_value), }; Ok(value) } else { - let jump_if_false = matches!(binary_expr.op, ast::BinOrCmpOp::Bin(ast::BinOp::And)); + let jump_if_false = matches!(binary_expr.op, ast::BinOp::And); let start_block = self.append_block(""); let value_block = self.append_block(""); let end_block = self.append_block(""); diff --git a/kclvm/parser/src/parser/expr.rs b/kclvm/parser/src/parser/expr.rs index 6ad169a0c..dce61e7b3 100644 --- a/kclvm/parser/src/parser/expr.rs +++ b/kclvm/parser/src/parser/expr.rs @@ -210,33 +210,37 @@ impl<'a> Parser<'a> { let y = self.do_parse_simple_expr(oprec); - // compare: a == b == c - if let BinOrCmpOp::Cmp(cmp_op) = op.clone() { - if cmp_expr.ops.is_empty() { - cmp_expr.left = x.clone(); + match op { + // compare: a == b == c + BinOrCmpOp::Cmp(cmp_op) => { + if cmp_expr.ops.is_empty() { + cmp_expr.left = x.clone(); + } + cmp_expr.ops.push(cmp_op); + cmp_expr.comparators.push(y); + continue; } - cmp_expr.ops.push(cmp_op); - cmp_expr.comparators.push(y); - continue; - } + // binary a + b + BinOrCmpOp::Bin(bin_op) => { + if !cmp_expr.ops.is_empty() { + x = Box::new(Node::node( + Expr::Compare(cmp_expr.clone()), + self.sess.struct_token_loc(token, self.prev_token), + )); + cmp_expr.ops = Vec::new(); + cmp_expr.comparators = Vec::new(); + } - if !cmp_expr.ops.is_empty() { - x = Box::new(Node::node( - Expr::Compare(cmp_expr.clone()), - self.sess.struct_token_loc(token, self.prev_token), - )); - cmp_expr.ops = Vec::new(); - cmp_expr.comparators = Vec::new(); + x = Box::new(Node::node( + Expr::Binary(BinaryExpr { + left: x, + op: bin_op, + right: y, + }), + self.sess.struct_token_loc(token, self.prev_token), + )); + } } - - x = Box::new(Node::node( - Expr::Binary(BinaryExpr { - left: x, - op, - right: y, - }), - self.sess.struct_token_loc(token, self.prev_token), - )); } } diff --git a/kclvm/parser/src/parser/stmt.rs b/kclvm/parser/src/parser/stmt.rs index 94d7c893e..80d8e8049 100644 --- a/kclvm/parser/src/parser/stmt.rs +++ b/kclvm/parser/src/parser/stmt.rs @@ -268,7 +268,7 @@ impl<'a> Parser<'a> { doc: "".to_string(), name: node_ref!(target.get_name(), targets[0].pos()), ty: ty.unwrap(), - op: Some(BinOrAugOp::Aug(aug_op)), + op: Some(aug_op), value: Some(value), is_optional: false, decorators: Vec::new(), @@ -1058,7 +1058,7 @@ impl<'a> Parser<'a> { assign.targets[0].pos() ), ty: assign.ty.unwrap(), - op: Some(BinOrAugOp::Aug(AugOp::Assign)), + op: Some(AugOp::Assign), value: Some(assign.value), is_optional: false, decorators: Vec::new(), @@ -1215,10 +1215,10 @@ impl<'a> Parser<'a> { let op = if self.token.kind == TokenKind::Assign { self.bump_token(TokenKind::Assign); - Some(BinOrAugOp::Aug(AugOp::Assign)) + Some(AugOp::Assign) } else if let TokenKind::BinOpEq(x) = self.token.kind { self.bump_token(self.token.kind); - Some(BinOrAugOp::Aug(x.into())) + Some(x.into()) } else { None }; diff --git a/kclvm/parser/src/parser/ty.rs b/kclvm/parser/src/parser/ty.rs index 05a23eca6..b3bd9882d 100644 --- a/kclvm/parser/src/parser/ty.rs +++ b/kclvm/parser/src/parser/ty.rs @@ -131,9 +131,15 @@ impl<'a> Parser<'a> { let v = lit.symbol.as_str().parse::().unwrap(); if let Some(suffix) = lit.suffix { let x = ast::NumberBinarySuffix::try_from(suffix.as_str().as_str()); - ast::LiteralType::Int(v, Some(x.unwrap())) + ast::LiteralType::Int(ast::IntLiteralType { + value: v, + suffix: Some(x.unwrap()), + }) } else { - ast::LiteralType::Int(v, None) + ast::LiteralType::Int(ast::IntLiteralType { + value: v, + suffix: None, + }) } } token::LitKind::Float => { diff --git a/kclvm/parser/src/tests.rs b/kclvm/parser/src/tests.rs index 4934fe4ac..5dfb903e0 100644 --- a/kclvm/parser/src/tests.rs +++ b/kclvm/parser/src/tests.rs @@ -117,7 +117,7 @@ pub(crate) fn parsing_type_string(src: &str) -> String { let stream = parse_token_streams(sess, src, new_byte_pos(0)); let mut parser = Parser::new(sess, stream); let typ = parser.parse_type_annotation(); - format!("{typ:?}\n") + format!("{typ:#?}\n") }) } diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__assign_stmt.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__assign_stmt.snap index 05bac82f1..28e67a473 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__assign_stmt.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__assign_stmt.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/ast.rs -assertion_line: 36 expression: "crate::tests::parsing_file_ast_json(\"hello.k\", r####\"a=123\"####)" --- { @@ -12,49 +11,45 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\", r####\"a=123\"#### { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 123 + "names": [ + { + "node": "a", + "filename": "hello.k", + "line": 1, + "column": 0, + "end_line": 1, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 1, - "column": 2, + "column": 0, "end_line": 1, - "end_column": 5 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 123 + } }, - "ty": null - } + "filename": "hello.k", + "line": 1, + "column": 2, + "end_line": 1, + "end_column": 5 + }, + "ty": null }, "filename": "hello.k", "line": 1, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__basic_stmt.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__basic_stmt.snap index a52d79d7e..84642f4ef 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__basic_stmt.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__basic_stmt.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/ast.rs -assertion_line: 59 expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\n# comment1\na = 1\n# comment22\nb = 2\n# comment333\nc = 3 # comment4444\n \"####)" --- { @@ -12,49 +11,45 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\n# co { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 + "names": [ + { + "node": "a", + "filename": "hello.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 3, - "column": 4, + "column": 0, "end_line": 3, - "end_column": 5 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } }, - "ty": null - } + "filename": "hello.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 5 + }, + "ty": null }, "filename": "hello.k", "line": 3, @@ -65,49 +60,45 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\n# co { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "b", - "filename": "hello.k", - "line": 5, - "column": 0, - "end_line": 5, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 5, - "column": 0, - "end_line": 5, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 + "names": [ + { + "node": "b", + "filename": "hello.k", + "line": 5, + "column": 0, + "end_line": 5, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 5, - "column": 4, + "column": 0, "end_line": 5, - "end_column": 5 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 + } }, - "ty": null - } + "filename": "hello.k", + "line": 5, + "column": 4, + "end_line": 5, + "end_column": 5 + }, + "ty": null }, "filename": "hello.k", "line": 5, @@ -118,49 +109,45 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\n# co { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "c", - "filename": "hello.k", - "line": 7, - "column": 0, - "end_line": 7, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 7, - "column": 0, - "end_line": 7, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 3 + "names": [ + { + "node": "c", + "filename": "hello.k", + "line": 7, + "column": 0, + "end_line": 7, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 7, - "column": 4, + "column": 0, "end_line": 7, - "end_column": 5 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 3 + } }, - "ty": null - } + "filename": "hello.k", + "line": 7, + "column": 4, + "end_line": 7, + "end_column": 5 + }, + "ty": null }, "filename": "hello.k", "line": 7, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_0.snap index ccec9abdb..d7cc9954f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_0.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/ast.rs -assertion_line: 37 expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\na = 10\nb = 12\n_condition = 0\nif a == 11 or b == 13: _condition = 1\nelif a == 10 and b == 12: _condition = 2\ncondition = _condition\n \"####)" --- { @@ -12,49 +11,45 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\na = { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 2, - "column": 0, - "end_line": 2, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 2, - "column": 0, - "end_line": 2, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 10 + "names": [ + { + "node": "a", + "filename": "hello.k", + "line": 2, + "column": 0, + "end_line": 2, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 2, - "column": 4, + "column": 0, "end_line": 2, - "end_column": 6 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 10 + } }, - "ty": null - } + "filename": "hello.k", + "line": 2, + "column": 4, + "end_line": 2, + "end_column": 6 + }, + "ty": null }, "filename": "hello.k", "line": 2, @@ -65,49 +60,45 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\na = { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "b", - "filename": "hello.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 12 + "names": [ + { + "node": "b", + "filename": "hello.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 3, - "column": 4, + "column": 0, "end_line": 3, - "end_column": 6 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 12 + } }, - "ty": null - } + "filename": "hello.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 6 + }, + "ty": null }, "filename": "hello.k", "line": 3, @@ -118,49 +109,45 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\na = { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "_condition", - "filename": "hello.k", - "line": 4, - "column": 0, - "end_line": 4, - "end_column": 10 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 4, - "column": 0, - "end_line": 4, - "end_column": 10 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 0 + "names": [ + { + "node": "_condition", + "filename": "hello.k", + "line": 4, + "column": 0, + "end_line": 4, + "end_column": 10 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 4, - "column": 13, + "column": 0, "end_line": 4, - "end_column": 14 + "end_column": 10 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 0 + } }, - "ty": null - } + "filename": "hello.k", + "line": 4, + "column": 13, + "end_line": 4, + "end_column": 14 + }, + "ty": null }, "filename": "hello.k", "line": 4, @@ -171,220 +158,186 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\na = { "node": { "type": "If", - "data": { - "body": [ - { - "node": { - "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "_condition", - "filename": "hello.k", - "line": 5, - "column": 23, - "end_line": 5, - "end_column": 33 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 5, - "column": 23, - "end_line": 5, - "end_column": 33 - } - ], - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } + "body": [ + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ + { + "node": "_condition", + "filename": "hello.k", + "line": 5, + "column": 23, + "end_line": 5, + "end_column": 33 } - }, - "filename": "hello.k", - "line": 5, - "column": 36, - "end_line": 5, - "end_column": 37 + ], + "pkgpath": "", + "ctx": "Store" }, - "ty": null + "filename": "hello.k", + "line": 5, + "column": 23, + "end_line": 5, + "end_column": 33 } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "hello.k", + "line": 5, + "column": 36, + "end_line": 5, + "end_column": 37 }, - "filename": "hello.k", - "line": 5, - "column": 23, - "end_line": 5, - "end_column": 37 - } - ], - "cond": { - "node": { - "type": "Binary", - "data": { + "ty": null + }, + "filename": "hello.k", + "line": 5, + "column": 23, + "end_line": 5, + "end_column": 37 + } + ], + "cond": { + "node": { + "type": "Binary", + "left": { + "node": { + "type": "Compare", "left": { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 5, - "column": 3, - "end_line": 5, - "end_column": 4 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "a", "filename": "hello.k", "line": 5, "column": 3, "end_line": 5, "end_column": 4 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 11 - } - } - }, - "filename": "hello.k", - "line": 5, - "column": 8, - "end_line": 5, - "end_column": 10 - } - ] - } + } + ], + "pkgpath": "", + "ctx": "Load" }, "filename": "hello.k", "line": 5, "column": 3, "end_line": 5, - "end_column": 21 - }, - "op": { - "type": "Bin", - "data": "Or" + "end_column": 4 }, - "right": { + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 11 + } + }, + "filename": "hello.k", + "line": 5, + "column": 8, + "end_line": 5, + "end_column": 10 + } + ] + }, + "filename": "hello.k", + "line": 5, + "column": 3, + "end_line": 5, + "end_column": 21 + }, + "op": "Or", + "right": { + "node": { + "type": "Compare", + "left": { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "b", - "filename": "hello.k", - "line": 5, - "column": 14, - "end_line": 5, - "end_column": 15 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "b", "filename": "hello.k", "line": 5, "column": 14, "end_line": 5, "end_column": 15 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 13 - } - } - }, - "filename": "hello.k", - "line": 5, - "column": 19, - "end_line": 5, - "end_column": 21 - } - ] - } + } + ], + "pkgpath": "", + "ctx": "Load" }, "filename": "hello.k", "line": 5, "column": 14, "end_line": 5, - "end_column": 21 - } - } - }, - "filename": "hello.k", - "line": 5, - "column": 3, - "end_line": 5, - "end_column": 21 + "end_column": 15 + }, + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 13 + } + }, + "filename": "hello.k", + "line": 5, + "column": 19, + "end_line": 5, + "end_column": 21 + } + ] + }, + "filename": "hello.k", + "line": 5, + "column": 14, + "end_line": 5, + "end_column": 21 + } }, - "orelse": [ - { - "node": { - "type": "If", - "data": { - "body": [ - { - "node": { - "type": "Assign", - "data": { - "targets": [ + "filename": "hello.k", + "line": 5, + "column": 3, + "end_line": 5, + "end_column": 21 + }, + "orelse": [ + { + "node": { + "type": "If", + "body": [ + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ { - "node": { - "names": [ - { - "node": "_condition", - "filename": "hello.k", - "line": 6, - "column": 26, - "end_line": 6, - "end_column": 36 - } - ], - "pkgpath": "", - "ctx": "Store" - }, + "node": "_condition", "filename": "hello.k", "line": 6, "column": 26, @@ -392,176 +345,164 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\na = "end_column": 36 } ], - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } - } - }, - "filename": "hello.k", - "line": 6, - "column": 39, - "end_line": 6, - "end_column": 40 - }, - "ty": null + "pkgpath": "", + "ctx": "Store" + }, + "filename": "hello.k", + "line": 6, + "column": 26, + "end_line": 6, + "end_column": 36 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 } }, "filename": "hello.k", "line": 6, - "column": 26, + "column": 39, "end_line": 6, "end_column": 40 - } - ], - "cond": { + }, + "ty": null + }, + "filename": "hello.k", + "line": 6, + "column": 26, + "end_line": 6, + "end_column": 40 + } + ], + "cond": { + "node": { + "type": "Binary", + "left": { "node": { - "type": "Binary", - "data": { - "left": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "a", + "filename": "hello.k", + "line": 6, + "column": 5, + "end_line": 6, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 6, + "column": 5, + "end_line": 6, + "end_column": 6 + }, + "ops": [ + "Eq" + ], + "comparators": [ + { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 6, - "column": 5, - "end_line": 6, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 6, - "column": 5, - "end_line": 6, - "end_column": 6 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 10 - } - } - }, - "filename": "hello.k", - "line": 6, - "column": 10, - "end_line": 6, - "end_column": 12 - } - ] + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 10 } }, "filename": "hello.k", "line": 6, - "column": 5, + "column": 10, "end_line": 6, - "end_column": 24 - }, - "op": { - "type": "Bin", - "data": "And" + "end_column": 12 + } + ] + }, + "filename": "hello.k", + "line": 6, + "column": 5, + "end_line": 6, + "end_column": 24 + }, + "op": "And", + "right": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "b", + "filename": "hello.k", + "line": 6, + "column": 17, + "end_line": 6, + "end_column": 18 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "right": { + "filename": "hello.k", + "line": 6, + "column": 17, + "end_line": 6, + "end_column": 18 + }, + "ops": [ + "Eq" + ], + "comparators": [ + { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "b", - "filename": "hello.k", - "line": 6, - "column": 17, - "end_line": 6, - "end_column": 18 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 6, - "column": 17, - "end_line": 6, - "end_column": 18 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 12 - } - } - }, - "filename": "hello.k", - "line": 6, - "column": 22, - "end_line": 6, - "end_column": 24 - } - ] + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 12 } }, "filename": "hello.k", "line": 6, - "column": 17, + "column": 22, "end_line": 6, "end_column": 24 } - } + ] }, "filename": "hello.k", "line": 6, - "column": 5, + "column": 17, "end_line": 6, "end_column": 24 - }, - "orelse": [] - } + } + }, + "filename": "hello.k", + "line": 6, + "column": 5, + "end_line": 6, + "end_column": 24 }, - "filename": "hello.k", - "line": 6, - "column": 0, - "end_line": 7, - "end_column": 0 - } - ] - } + "orelse": [] + }, + "filename": "hello.k", + "line": 6, + "column": 0, + "end_line": 7, + "end_column": 0 + } + ] }, "filename": "hello.k", "line": 5, @@ -572,56 +513,52 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\na = { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "condition", - "filename": "hello.k", - "line": 7, - "column": 0, - "end_line": 7, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 7, - "column": 0, - "end_line": 7, - "end_column": 9 - } - ], - "value": { + "targets": [ + { "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_condition", - "filename": "hello.k", - "line": 7, - "column": 12, - "end_line": 7, - "end_column": 22 - } - ], - "pkgpath": "", - "ctx": "Load" - } + "names": [ + { + "node": "condition", + "filename": "hello.k", + "line": 7, + "column": 0, + "end_line": 7, + "end_column": 9 + } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "hello.k", "line": 7, - "column": 12, + "column": 0, "end_line": 7, - "end_column": 22 + "end_column": 9 + } + ], + "value": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "_condition", + "filename": "hello.k", + "line": 7, + "column": 12, + "end_line": 7, + "end_column": 22 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "ty": null - } + "filename": "hello.k", + "line": 7, + "column": 12, + "end_line": 7, + "end_column": 22 + }, + "ty": null }, "filename": "hello.k", "line": 7, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_1.snap index 0468e901c..7f721f719 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__if_stmt_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/ast.rs -assertion_line: 49 expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\ndata2 = {\n **{key = \"value1\"}\n if a == 123: if b == 456: key = \"value2\"\n}\n \"####)" --- { @@ -12,342 +11,312 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\ndata { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "data2", - "filename": "hello.k", - "line": 2, - "column": 0, - "end_line": 2, - "end_column": 5 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "hello.k", - "line": 2, - "column": 0, - "end_line": 2, - "end_column": 5 - } - ], - "value": { + "targets": [ + { "node": { - "type": "Config", - "data": { - "items": [ - { + "names": [ + { + "node": "data2", + "filename": "hello.k", + "line": 2, + "column": 0, + "end_line": 2, + "end_column": 5 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "hello.k", + "line": 2, + "column": 0, + "end_line": 2, + "end_column": 5 + } + ], + "value": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": null, + "value": { "node": { - "key": null, - "value": { - "node": { - "type": "Config", - "data": { - "items": [ - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "key", - "filename": "hello.k", - "line": 3, - "column": 7, - "end_line": 3, - "end_column": 10 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "key", "filename": "hello.k", "line": 3, "column": 7, "end_line": 3, "end_column": 10 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"value1\"", - "value": "value1" - } - }, - "filename": "hello.k", - "line": 3, - "column": 13, - "end_line": 3, - "end_column": 21 - }, - "operation": "Override", - "insert_index": -1 - }, - "filename": "hello.k", - "line": 3, - "column": 7, - "end_line": 3, - "end_column": 21 - } - ] - } - }, - "filename": "hello.k", - "line": 3, - "column": 6, - "end_line": 3, - "end_column": 22 - }, - "operation": "Union", - "insert_index": -1 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 3, + "column": 7, + "end_line": 3, + "end_column": 10 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"value1\"", + "value": "value1" + }, + "filename": "hello.k", + "line": 3, + "column": 13, + "end_line": 3, + "end_column": 21 + }, + "operation": "Override", + "insert_index": -1 + }, + "filename": "hello.k", + "line": 3, + "column": 7, + "end_line": 3, + "end_column": 21 + } + ] }, "filename": "hello.k", "line": 3, - "column": 4, + "column": 6, "end_line": 3, "end_column": 22 }, - { + "operation": "Union", + "insert_index": -1 + }, + "filename": "hello.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 22 + }, + { + "node": { + "key": null, + "value": { "node": { - "key": null, - "value": { + "type": "ConfigIfEntry", + "if_cond": { "node": { - "type": "ConfigIfEntry", - "data": { - "if_cond": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "a", + "filename": "hello.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 8 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 8 + }, + "ops": [ + "Eq" + ], + "comparators": [ + { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 123 + } + }, + "filename": "hello.k", + "line": 4, + "column": 12, + "end_line": 4, + "end_column": 15 + } + ] + }, + "filename": "hello.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 15 + }, + "items": [ + { + "node": { + "key": null, + "value": { + "node": { + "type": "ConfigIfEntry", + "if_cond": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", "names": [ { - "node": "a", + "node": "b", "filename": "hello.k", "line": 4, - "column": 7, + "column": 20, "end_line": 4, - "end_column": 8 + "end_column": 21 } ], "pkgpath": "", "ctx": "Load" - } + }, + "filename": "hello.k", + "line": 4, + "column": 20, + "end_line": 4, + "end_column": 21 }, - "filename": "hello.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 8 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "NumberLit", "binary_suffix": null, "value": { "type": "Int", - "data": 123 + "value": 456 } - } - }, - "filename": "hello.k", - "line": 4, - "column": 12, - "end_line": 4, - "end_column": 15 - } - ] - } - }, - "filename": "hello.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 15 - }, - "items": [ - { - "node": { - "key": null, - "value": { + }, + "filename": "hello.k", + "line": 4, + "column": 25, + "end_line": 4, + "end_column": 28 + } + ] + }, + "filename": "hello.k", + "line": 4, + "column": 20, + "end_line": 4, + "end_column": 28 + }, + "items": [ + { "node": { - "type": "ConfigIfEntry", - "data": { - "if_cond": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "b", - "filename": "hello.k", - "line": 4, - "column": 20, - "end_line": 4, - "end_column": 21 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 4, - "column": 20, - "end_line": 4, - "end_column": 21 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 456 - } - } - }, - "filename": "hello.k", - "line": 4, - "column": 25, - "end_line": 4, - "end_column": 28 - } - ] + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "key", + "filename": "hello.k", + "line": 4, + "column": 30, + "end_line": 4, + "end_column": 33 } - }, - "filename": "hello.k", - "line": 4, - "column": 20, - "end_line": 4, - "end_column": 28 + ], + "pkgpath": "", + "ctx": "Load" }, - "items": [ - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "key", - "filename": "hello.k", - "line": 4, - "column": 30, - "end_line": 4, - "end_column": 33 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 4, - "column": 30, - "end_line": 4, - "end_column": 33 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"value2\"", - "value": "value2" - } - }, - "filename": "hello.k", - "line": 4, - "column": 36, - "end_line": 4, - "end_column": 44 - }, - "operation": "Override", - "insert_index": -1 - }, - "filename": "hello.k", - "line": 4, - "column": 30, - "end_line": 4, - "end_column": 44 - } - ], - "orelse": null - } + "filename": "hello.k", + "line": 4, + "column": 30, + "end_line": 4, + "end_column": 33 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"value2\"", + "value": "value2" + }, + "filename": "hello.k", + "line": 4, + "column": 36, + "end_line": 4, + "end_column": 44 + }, + "operation": "Override", + "insert_index": -1 }, "filename": "hello.k", "line": 4, - "column": 17, - "end_line": 5, - "end_column": 0 - }, - "operation": "Override", - "insert_index": -1 - }, - "filename": "hello.k", - "line": 4, - "column": 17, - "end_line": 5, - "end_column": 0 - } - ], - "orelse": null - } - }, - "filename": "hello.k", - "line": 4, - "column": 4, - "end_line": 5, - "end_column": 0 - }, - "operation": "Union", - "insert_index": -1 + "column": 30, + "end_line": 4, + "end_column": 44 + } + ], + "orelse": null + }, + "filename": "hello.k", + "line": 4, + "column": 17, + "end_line": 5, + "end_column": 0 + }, + "operation": "Override", + "insert_index": -1 + }, + "filename": "hello.k", + "line": 4, + "column": 17, + "end_line": 5, + "end_column": 0 + } + ], + "orelse": null }, "filename": "hello.k", "line": 4, "column": 4, "end_line": 5, "end_column": 0 - } - ] + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "hello.k", + "line": 4, + "column": 4, + "end_line": 5, + "end_column": 0 } - }, - "filename": "hello.k", - "line": 2, - "column": 8, - "end_line": 5, - "end_column": 1 + ] }, - "ty": null - } + "filename": "hello.k", + "line": 2, + "column": 8, + "end_line": 5, + "end_column": 1 + }, + "ty": null }, "filename": "hello.k", "line": 2, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap index 34d1114db..fe180f810 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__ast__schema_stmt.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/ast.rs -assertion_line: 3 expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nschema TestBool:\n []\n [str ]: int\n [a: str]: int\n [a: ...str]: int\n [...str]: int\n a: int\n b?: str\n c: int = 0\n d?: str = \"\"\n\n [a]\n [a, b, c]\n [\n 1\n ]\n [\n a\n ]\n [a for a in [1, 2, 3]]\n [\n a for a in [1, 2, 3]\n ]\n\n check:\n a > 1, \"msg\"\n name not None, \"we fail here\"\n \"####)" --- { @@ -12,259 +11,222 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche { "node": { "type": "Schema", - "data": { - "doc": null, - "name": { - "node": "TestBool", + "doc": null, + "name": { + "node": "TestBool", + "filename": "hello.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 15 + }, + "parent_name": null, + "for_host_name": null, + "is_mixin": false, + "is_protocol": false, + "args": null, + "mixins": [], + "body": [ + { + "node": { + "type": "Expr", + "exprs": [ + { + "node": { + "type": "List", + "elts": [], + "ctx": "Load" + }, + "filename": "hello.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 6 + } + ] + }, "filename": "hello.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 15 + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 6 }, - "parent_name": null, - "for_host_name": null, - "is_mixin": false, - "is_protocol": false, - "args": null, - "mixins": [], - "body": [ - { - "node": { - "type": "Expr", - "data": { - "exprs": [ - { - "node": { - "type": "List", - "data": { - "elts": [], - "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 6 - } - ] - } + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "a", + "filename": "hello.k", + "line": 8, + "column": 4, + "end_line": 8, + "end_column": 5 }, - "filename": "hello.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 6 + "op": null, + "value": null, + "is_optional": false, + "decorators": [], + "ty": { + "node": { + "type": "Basic", + "value": "Int" + }, + "filename": "hello.k", + "line": 8, + "column": 7, + "end_line": 8, + "end_column": 10 + } }, - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "a", - "filename": "hello.k", - "line": 8, - "column": 4, - "end_line": 8, - "end_column": 5 - }, - "op": null, - "value": null, - "is_optional": false, - "decorators": [], - "ty": { - "node": { - "type": "Basic", - "data": "Int" - }, - "filename": "hello.k", - "line": 8, - "column": 7, - "end_line": 8, - "end_column": 10 - } - } + "filename": "hello.k", + "line": 8, + "column": 4, + "end_line": 8, + "end_column": 10 + }, + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "b", + "filename": "hello.k", + "line": 9, + "column": 4, + "end_line": 9, + "end_column": 5 }, - "filename": "hello.k", - "line": 8, - "column": 4, - "end_line": 8, - "end_column": 10 + "op": null, + "value": null, + "is_optional": true, + "decorators": [], + "ty": { + "node": { + "type": "Basic", + "value": "Str" + }, + "filename": "hello.k", + "line": 9, + "column": 8, + "end_line": 9, + "end_column": 11 + } }, - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "b", - "filename": "hello.k", - "line": 9, - "column": 4, - "end_line": 9, - "end_column": 5 - }, - "op": null, - "value": null, - "is_optional": true, - "decorators": [], - "ty": { - "node": { - "type": "Basic", - "data": "Str" - }, - "filename": "hello.k", - "line": 9, - "column": 8, - "end_line": 9, - "end_column": 11 - } - } + "filename": "hello.k", + "line": 9, + "column": 4, + "end_line": 10, + "end_column": 0 + }, + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "c", + "filename": "hello.k", + "line": 10, + "column": 4, + "end_line": 10, + "end_column": 5 }, - "filename": "hello.k", - "line": 9, - "column": 4, - "end_line": 10, - "end_column": 0 - }, - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "c", - "filename": "hello.k", - "line": 10, - "column": 4, - "end_line": 10, - "end_column": 5 - }, - "op": { - "type": "Aug", - "data": "Assign" - }, + "op": "Assign", + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 0 - } - } - }, - "filename": "hello.k", - "line": 10, - "column": 13, - "end_line": 10, - "end_column": 14 - }, - "is_optional": false, - "decorators": [], - "ty": { - "node": { - "type": "Basic", - "data": "Int" - }, - "filename": "hello.k", - "line": 10, - "column": 7, - "end_line": 10, - "end_column": 10 + "type": "Int", + "value": 0 } - } + }, + "filename": "hello.k", + "line": 10, + "column": 13, + "end_line": 10, + "end_column": 14 }, - "filename": "hello.k", - "line": 10, - "column": 4, - "end_line": 10, - "end_column": 14 + "is_optional": false, + "decorators": [], + "ty": { + "node": { + "type": "Basic", + "value": "Int" + }, + "filename": "hello.k", + "line": 10, + "column": 7, + "end_line": 10, + "end_column": 10 + } }, - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "d", - "filename": "hello.k", - "line": 11, - "column": 4, - "end_line": 11, - "end_column": 5 - }, - "op": { - "type": "Aug", - "data": "Assign" - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"\"", - "value": "" - } - }, - "filename": "hello.k", - "line": 11, - "column": 14, - "end_line": 11, - "end_column": 16 - }, - "is_optional": true, - "decorators": [], - "ty": { - "node": { - "type": "Basic", - "data": "Str" - }, - "filename": "hello.k", - "line": 11, - "column": 8, - "end_line": 11, - "end_column": 11 - } - } + "filename": "hello.k", + "line": 10, + "column": 4, + "end_line": 10, + "end_column": 14 + }, + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "d", + "filename": "hello.k", + "line": 11, + "column": 4, + "end_line": 11, + "end_column": 5 }, - "filename": "hello.k", - "line": 11, - "column": 4, - "end_line": 13, - "end_column": 0 + "op": "Assign", + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"\"", + "value": "" + }, + "filename": "hello.k", + "line": 11, + "column": 14, + "end_line": 11, + "end_column": 16 + }, + "is_optional": true, + "decorators": [], + "ty": { + "node": { + "type": "Basic", + "value": "Str" + }, + "filename": "hello.k", + "line": 11, + "column": 8, + "end_line": 11, + "end_column": 11 + } }, - { - "node": { - "type": "Expr", - "data": { - "exprs": [ - { - "node": { - "type": "List", - "data": { - "elts": [ + "filename": "hello.k", + "line": 11, + "column": 4, + "end_line": 13, + "end_column": 0 + }, + { + "node": { + "type": "Expr", + "exprs": [ + { + "node": { + "type": "List", + "elts": [ + { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 13, - "column": 5, - "end_line": 13, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "node": "a", "filename": "hello.k", "line": 13, "column": 5, @@ -272,100 +234,90 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "end_column": 6 } ], + "pkgpath": "", "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 13, - "column": 4, - "end_line": 13, - "end_column": 7 - } - ] + }, + "filename": "hello.k", + "line": 13, + "column": 5, + "end_line": 13, + "end_column": 6 + } + ], + "ctx": "Load" + }, + "filename": "hello.k", + "line": 13, + "column": 4, + "end_line": 13, + "end_column": 7 } - }, - "filename": "hello.k", - "line": 13, - "column": 4, - "end_line": 13, - "end_column": 7 + ] }, - { - "node": { - "type": "Expr", - "data": { - "exprs": [ - { - "node": { - "type": "List", - "data": { - "elts": [ + "filename": "hello.k", + "line": 13, + "column": 4, + "end_line": 13, + "end_column": 7 + }, + { + "node": { + "type": "Expr", + "exprs": [ + { + "node": { + "type": "List", + "elts": [ + { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 14, - "column": 5, - "end_line": 14, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "node": "a", "filename": "hello.k", "line": 14, "column": 5, "end_line": 14, "end_column": 6 - }, + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 14, + "column": 5, + "end_line": 14, + "end_column": 6 + }, + { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "b", - "filename": "hello.k", - "line": 14, - "column": 8, - "end_line": 14, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "node": "b", "filename": "hello.k", "line": 14, "column": 8, "end_line": 14, "end_column": 9 - }, + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 14, + "column": 8, + "end_line": 14, + "end_column": 9 + }, + { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "c", - "filename": "hello.k", - "line": 14, - "column": 11, - "end_line": 14, - "end_column": 12 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "node": "c", "filename": "hello.k", "line": 14, "column": 11, @@ -373,98 +325,86 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "end_column": 12 } ], + "pkgpath": "", "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 14, - "column": 4, - "end_line": 14, - "end_column": 13 - } - ] + }, + "filename": "hello.k", + "line": 14, + "column": 11, + "end_line": 14, + "end_column": 12 + } + ], + "ctx": "Load" + }, + "filename": "hello.k", + "line": 14, + "column": 4, + "end_line": 14, + "end_column": 13 } - }, - "filename": "hello.k", - "line": 14, - "column": 4, - "end_line": 14, - "end_column": 13 + ] }, - { - "node": { - "type": "Expr", - "data": { - "exprs": [ - { - "node": { - "type": "List", - "data": { - "elts": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "hello.k", - "line": 16, - "column": 8, - "end_line": 16, - "end_column": 9 - } - ], - "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 15, - "column": 4, - "end_line": 17, - "end_column": 5 - } - ] + "filename": "hello.k", + "line": 14, + "column": 4, + "end_line": 14, + "end_column": 13 + }, + { + "node": { + "type": "Expr", + "exprs": [ + { + "node": { + "type": "List", + "elts": [ + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "hello.k", + "line": 16, + "column": 8, + "end_line": 16, + "end_column": 9 + } + ], + "ctx": "Load" + }, + "filename": "hello.k", + "line": 15, + "column": 4, + "end_line": 17, + "end_column": 5 } - }, - "filename": "hello.k", - "line": 15, - "column": 4, - "end_line": 17, - "end_column": 5 + ] }, - { - "node": { - "type": "Expr", - "data": { - "exprs": [ - { - "node": { - "type": "List", - "data": { - "elts": [ + "filename": "hello.k", + "line": 15, + "column": 4, + "end_line": 17, + "end_column": 5 + }, + { + "node": { + "type": "Expr", + "exprs": [ + { + "node": { + "type": "List", + "elts": [ + { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 19, - "column": 8, - "end_line": 19, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "node": "a", "filename": "hello.k", "line": 19, "column": 8, @@ -472,76 +412,70 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "end_column": 9 } ], + "pkgpath": "", "ctx": "Load" - } - }, - "filename": "hello.k", - "line": 18, - "column": 4, - "end_line": 20, - "end_column": 5 - } - ] + }, + "filename": "hello.k", + "line": 19, + "column": 8, + "end_line": 19, + "end_column": 9 + } + ], + "ctx": "Load" + }, + "filename": "hello.k", + "line": 18, + "column": 4, + "end_line": 20, + "end_column": 5 } - }, - "filename": "hello.k", - "line": 18, - "column": 4, - "end_line": 20, - "end_column": 5 - }, - { - "node": { - "type": "Expr", - "data": { - "exprs": [ - { + ] + }, + "filename": "hello.k", + "line": 18, + "column": 4, + "end_line": 20, + "end_column": 5 + }, + { + "node": { + "type": "Expr", + "exprs": [ + { + "node": { + "type": "ListComp", + "elt": { "node": { - "type": "ListComp", - "data": { - "elt": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 21, - "column": 5, - "end_line": 21, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "a", "filename": "hello.k", "line": 21, "column": 5, "end_line": 21, "end_column": 6 - }, - "generators": [ + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 21, + "column": 5, + "end_line": 21, + "end_column": 6 + }, + "generators": [ + { + "node": { + "targets": [ { "node": { - "targets": [ + "names": [ { - "node": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 21, - "column": 11, - "end_line": 21, - "end_column": 12 - } - ], - "pkgpath": "", - "ctx": "Load" - }, + "node": "a", "filename": "hello.k", "line": 21, "column": 11, @@ -549,150 +483,136 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "end_column": 12 } ], - "iter": { + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 21, + "column": 11, + "end_line": 21, + "end_column": 12 + } + ], + "iter": { + "node": { + "type": "List", + "elts": [ + { "node": { - "type": "List", - "data": { - "elts": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "hello.k", - "line": 21, - "column": 17, - "end_line": 21, - "end_column": 18 - }, - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } - } - }, - "filename": "hello.k", - "line": 21, - "column": 20, - "end_line": 21, - "end_column": 21 - }, - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 3 - } - } - }, - "filename": "hello.k", - "line": 21, - "column": 23, - "end_line": 21, - "end_column": 24 - } - ], - "ctx": "Load" + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 } }, "filename": "hello.k", "line": 21, - "column": 16, + "column": 17, "end_line": 21, - "end_column": 25 + "end_column": 18 }, - "ifs": [] - }, - "filename": "hello.k", - "line": 21, - "column": 7, - "end_line": 21, - "end_column": 25 - } - ] - } - }, - "filename": "hello.k", - "line": 21, - "column": 4, - "end_line": 21, - "end_column": 26 - } - ] + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 + } + }, + "filename": "hello.k", + "line": 21, + "column": 20, + "end_line": 21, + "end_column": 21 + }, + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 3 + } + }, + "filename": "hello.k", + "line": 21, + "column": 23, + "end_line": 21, + "end_column": 24 + } + ], + "ctx": "Load" + }, + "filename": "hello.k", + "line": 21, + "column": 16, + "end_line": 21, + "end_column": 25 + }, + "ifs": [] + }, + "filename": "hello.k", + "line": 21, + "column": 7, + "end_line": 21, + "end_column": 25 + } + ] + }, + "filename": "hello.k", + "line": 21, + "column": 4, + "end_line": 21, + "end_column": 26 } - }, - "filename": "hello.k", - "line": 21, - "column": 4, - "end_line": 21, - "end_column": 26 + ] }, - { - "node": { - "type": "Expr", - "data": { - "exprs": [ - { + "filename": "hello.k", + "line": 21, + "column": 4, + "end_line": 21, + "end_column": 26 + }, + { + "node": { + "type": "Expr", + "exprs": [ + { + "node": { + "type": "ListComp", + "elt": { "node": { - "type": "ListComp", - "data": { - "elt": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 23, - "column": 8, - "end_line": 23, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "a", "filename": "hello.k", "line": 23, "column": 8, "end_line": 23, "end_column": 9 - }, - "generators": [ + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 23, + "column": 8, + "end_line": 23, + "end_column": 9 + }, + "generators": [ + { + "node": { + "targets": [ { "node": { - "targets": [ + "names": [ { - "node": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 23, - "column": 14, - "end_line": 23, - "end_column": 15 - } - ], - "pkgpath": "", - "ctx": "Load" - }, + "node": "a", "filename": "hello.k", "line": 23, "column": 14, @@ -700,305 +620,288 @@ expression: "crate::tests::parsing_file_ast_json(\"hello.k\",\n r####\"\nsche "end_column": 15 } ], - "iter": { + "pkgpath": "", + "ctx": "Load" + }, + "filename": "hello.k", + "line": 23, + "column": 14, + "end_line": 23, + "end_column": 15 + } + ], + "iter": { + "node": { + "type": "List", + "elts": [ + { "node": { - "type": "List", - "data": { - "elts": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "hello.k", - "line": 23, - "column": 20, - "end_line": 23, - "end_column": 21 - }, - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } - } - }, - "filename": "hello.k", - "line": 23, - "column": 23, - "end_line": 23, - "end_column": 24 - }, - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 3 - } - } - }, - "filename": "hello.k", - "line": 23, - "column": 26, - "end_line": 23, - "end_column": 27 - } - ], - "ctx": "Load" + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 } }, "filename": "hello.k", "line": 23, - "column": 19, + "column": 20, "end_line": 23, - "end_column": 28 + "end_column": 21 }, - "ifs": [] - }, - "filename": "hello.k", - "line": 23, - "column": 10, - "end_line": 24, - "end_column": 0 - } - ] - } - }, - "filename": "hello.k", - "line": 22, - "column": 4, - "end_line": 24, - "end_column": 5 - } - ] - } - }, - "filename": "hello.k", - "line": 22, - "column": 4, - "end_line": 24, - "end_column": 5 - } - ], - "decorators": [], - "checks": [ - { - "node": { - "test": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "hello.k", - "line": 27, - "column": 8, - "end_line": 27, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Load" - } + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 + } + }, + "filename": "hello.k", + "line": 23, + "column": 23, + "end_line": 23, + "end_column": 24 + }, + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 3 + } + }, + "filename": "hello.k", + "line": 23, + "column": 26, + "end_line": 23, + "end_column": 27 + } + ], + "ctx": "Load" + }, + "filename": "hello.k", + "line": 23, + "column": 19, + "end_line": 23, + "end_column": 28 + }, + "ifs": [] }, "filename": "hello.k", - "line": 27, - "column": 8, - "end_line": 27, - "end_column": 9 - }, - "ops": [ - "Gt" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "hello.k", - "line": 27, - "column": 12, - "end_line": 27, - "end_column": 13 - } - ] - } - }, - "filename": "hello.k", - "line": 27, - "column": 8, - "end_line": 27, - "end_column": 13 - }, - "if_cond": null, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"msg\"", - "value": "msg" - } + "line": 23, + "column": 10, + "end_line": 24, + "end_column": 0 + } + ] }, "filename": "hello.k", - "line": 27, - "column": 15, - "end_line": 27, - "end_column": 20 + "line": 22, + "column": 4, + "end_line": 24, + "end_column": 5 } - }, - "filename": "hello.k", - "line": 27, - "column": 8, - "end_line": 27, - "end_column": 20 + ] }, - { - "node": { - "test": { - "node": { - "type": "Identifier", - "data": { + "filename": "hello.k", + "line": 22, + "column": 4, + "end_line": 24, + "end_column": 5 + } + ], + "decorators": [], + "checks": [ + { + "node": { + "test": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", "names": [ { - "node": "name", + "node": "a", "filename": "hello.k", - "line": 28, + "line": 27, "column": 8, - "end_line": 28, - "end_column": 12 + "end_line": 27, + "end_column": 9 } ], "pkgpath": "", "ctx": "Load" - } + }, + "filename": "hello.k", + "line": 27, + "column": 8, + "end_line": 27, + "end_column": 9 }, - "filename": "hello.k", - "line": 28, - "column": 8, - "end_line": 28, - "end_column": 12 + "ops": [ + "Gt" + ], + "comparators": [ + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "hello.k", + "line": 27, + "column": 12, + "end_line": 27, + "end_column": 13 + } + ] }, - "if_cond": null, - "msg": null + "filename": "hello.k", + "line": 27, + "column": 8, + "end_line": 27, + "end_column": 13 }, - "filename": "hello.k", - "line": 28, - "column": 8, - "end_line": 28, - "end_column": 12 + "if_cond": null, + "msg": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"msg\"", + "value": "msg" + }, + "filename": "hello.k", + "line": 27, + "column": 15, + "end_line": 27, + "end_column": 20 + } }, - { - "node": { - "test": { - "node": { - "type": "Unary", - "data": { - "op": "Not", - "operand": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "None" - } - }, - "filename": "hello.k", - "line": 28, - "column": 17, - "end_line": 28, - "end_column": 21 - } + "filename": "hello.k", + "line": 27, + "column": 8, + "end_line": 27, + "end_column": 20 + }, + { + "node": { + "test": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "name", + "filename": "hello.k", + "line": 28, + "column": 8, + "end_line": 28, + "end_column": 12 } - }, - "filename": "hello.k", - "line": 28, - "column": 13, - "end_line": 28, - "end_column": 21 + ], + "pkgpath": "", + "ctx": "Load" }, - "if_cond": null, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"we fail here\"", - "value": "we fail here" - } - }, - "filename": "hello.k", - "line": 28, - "column": 23, - "end_line": 28, - "end_column": 37 - } + "filename": "hello.k", + "line": 28, + "column": 8, + "end_line": 28, + "end_column": 12 }, - "filename": "hello.k", - "line": 28, - "column": 13, - "end_line": 28, - "end_column": 37 - } - ], - "index_signature": { + "if_cond": null, + "msg": null + }, + "filename": "hello.k", + "line": 28, + "column": 8, + "end_line": 28, + "end_column": 12 + }, + { "node": { - "key_name": null, - "value": null, - "any_other": true, - "key_ty": { + "test": { "node": { - "type": "Basic", - "data": "Str" + "type": "Unary", + "op": "Not", + "operand": { + "node": { + "type": "NameConstantLit", + "value": "None" + }, + "filename": "hello.k", + "line": 28, + "column": 17, + "end_line": 28, + "end_column": 21 + } }, "filename": "hello.k", - "line": 7, - "column": 8, - "end_line": 7, - "end_column": 11 + "line": 28, + "column": 13, + "end_line": 28, + "end_column": 21 }, - "value_ty": { + "if_cond": null, + "msg": { "node": { - "type": "Basic", - "data": "Int" + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"we fail here\"", + "value": "we fail here" }, "filename": "hello.k", - "line": 7, - "column": 14, - "end_line": 7, - "end_column": 17 + "line": 28, + "column": 23, + "end_line": 28, + "end_column": 37 } }, "filename": "hello.k", - "line": 7, - "column": 4, - "end_line": 8, - "end_column": 0 + "line": 28, + "column": 13, + "end_line": 28, + "end_column": 37 } + ], + "index_signature": { + "node": { + "key_name": null, + "value": null, + "any_other": true, + "key_ty": { + "node": { + "type": "Basic", + "value": "Str" + }, + "filename": "hello.k", + "line": 7, + "column": 8, + "end_line": 7, + "end_column": 11 + }, + "value_ty": { + "node": { + "type": "Basic", + "value": "Int" + }, + "filename": "hello.k", + "line": 7, + "column": 14, + "end_line": 7, + "end_column": 17 + } + }, + "filename": "hello.k", + "line": 7, + "column": 4, + "end_line": 8, + "end_column": 0 } }, "filename": "hello.k", diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_5.snap index 3b3317cca..c597b6281 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_5.snap @@ -28,9 +28,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Unary( UnaryExpr { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_6.snap index d2e237193..ad0ad2629 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_6.snap @@ -31,9 +31,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Sub, - ), + op: Sub, right: Node { node: Unary( UnaryExpr { @@ -64,9 +62,7 @@ Node { end_line: 1, end_column: 6, }, - op: Bin( - Sub, - ), + op: Sub, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_7.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_7.snap index ffa4d8b58..1f0594d49 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_7.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__binary_recovery_7.snap @@ -28,9 +28,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__compare_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__compare_recovery_3.snap index 0e59edb63..d7b4ce34f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__compare_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__compare_recovery_3.snap @@ -31,9 +31,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - LShift, - ), + op: LShift, right: Node { node: Missing( MissingExpr, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_10.snap index b1f1cd86b..88b7b2924 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_10.snap @@ -57,9 +57,7 @@ Node { end_line: 1, end_column: 7, }, - op: Bin( - Mul, - ), + op: Mul, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_12.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_12.snap index 508c0265c..9c2b072c7 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_12.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_12.snap @@ -41,9 +41,7 @@ Node { end_line: 1, end_column: 11, }, - op: Bin( - Mul, - ), + op: Mul, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_9.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_9.snap index e1b3f7712..a7a132f69 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_9.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__config_recovery_9.snap @@ -22,9 +22,7 @@ Node { end_line: 1, end_column: 2, }, - op: Bin( - Mul, - ), + op: Mul, right: Node { node: Identifier( Identifier { @@ -70,9 +68,7 @@ Node { end_line: 1, end_column: 7, }, - op: Bin( - Pow, - ), + op: Pow, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_1.snap index d766db909..9e1a8683e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_1.snap @@ -37,9 +37,7 @@ Node { end_line: 1, end_column: 4, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Missing( MissingExpr, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_2.snap index 52cb08957..7bdb64047 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_2.snap @@ -40,9 +40,7 @@ Node { end_line: 1, end_column: 5, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Missing( MissingExpr, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_5.snap index d4cd39402..c974dedbf 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__joined_string_recovery_5.snap @@ -37,9 +37,7 @@ Node { end_line: 1, end_column: 4, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_2.snap index 3a2f277ea..90d980588 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_2.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 23 expression: "crate::tests::parsing_expr_string(r#\"'a' + \\\n'b'\n\"#)" --- Node { @@ -20,9 +19,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: StringLit( StringLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_3.snap index 15a6a49fb..560f44c0f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__line_continue_recovery_3.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 26 expression: "crate::tests::parsing_expr_string(r#\"'a' + \\1\n'b'\n\"#)" --- Node { @@ -20,9 +19,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_10.snap index ce623a7e4..47087d246 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_10.snap @@ -19,9 +19,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Pow, - ), + op: Pow, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_12.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_12.snap index b7e8f0546..452d8d6fa 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_12.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_12.snap @@ -35,9 +35,7 @@ Node { end_line: 1, end_column: 12, }, - op: Bin( - Pow, - ), + op: Pow, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_9.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_9.snap index 1aeb4ed09..9d6ba6afb 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_9.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__list_recovery_9.snap @@ -54,9 +54,7 @@ Node { end_line: 1, end_column: 7, }, - op: Bin( - Pow, - ), + op: Pow, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_1.snap index 285ab845e..c5ab49249 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_1.snap @@ -31,9 +31,7 @@ Node { end_line: 1, end_column: 2, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_5.snap index d93c9b71b..de670e6df 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__paren_recovery_5.snap @@ -31,9 +31,7 @@ Node { end_line: 1, end_column: 2, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Missing( MissingExpr, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_5.snap index 99c80e731..b81c0b0e6 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_5.snap @@ -27,9 +27,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_6.snap index 3f045df32..4d52ae56e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_6.snap @@ -27,9 +27,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Sub, - ), + op: Sub, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_7.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_7.snap index c909a3f43..986f87af6 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_7.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__unary_recovery_7.snap @@ -27,9 +27,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_0.snap index ff497d920..5eff3ea53 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_0.snap @@ -23,9 +23,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { @@ -49,9 +47,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_1.snap index d5ea0857a..332c5dcc2 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_1.snap @@ -23,9 +23,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Binary( BinaryExpr { @@ -44,9 +42,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Mul, - ), + op: Mul, right: Node { node: NumberLit( NumberLit { @@ -78,9 +74,7 @@ Node { end_line: 1, end_column: 5, }, - op: Bin( - Sub, - ), + op: Sub, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_10.snap index 880406eae..97c2bc28e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_10.snap @@ -23,9 +23,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Identifier( Identifier { @@ -57,9 +55,7 @@ Node { end_line: 1, end_column: 5, }, - op: Bin( - And, - ), + op: And, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_2.snap index bf66dd48a..d401b95d2 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_2.snap @@ -20,9 +20,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Binary( BinaryExpr { @@ -44,9 +42,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Mul, - ), + op: Mul, right: Node { node: NumberLit( NumberLit { @@ -70,9 +66,7 @@ Node { end_line: 1, end_column: 5, }, - op: Bin( - Div, - ), + op: Div, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_3.snap index 2b7e42805..90eafbf74 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_3.snap @@ -28,9 +28,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Or, - ), + op: Or, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_4.snap index f95bc13af..2f4355574 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_4.snap @@ -67,9 +67,7 @@ Node { end_line: 1, end_column: 11, }, - op: Bin( - Or, - ), + op: Or, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_5.snap index 19b27602b..390202c20 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_5.snap @@ -51,9 +51,7 @@ Node { end_line: 1, end_column: 21, }, - op: Bin( - And, - ), + op: And, right: Node { node: Compare( Compare { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_6.snap index 55952d50b..cd1469496 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_6.snap @@ -104,9 +104,7 @@ Node { end_line: 1, end_column: 27, }, - op: Bin( - And, - ), + op: And, right: Node { node: Compare( Compare { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_9.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_9.snap index 54807efd4..416b34223 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_9.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_9.snap @@ -51,9 +51,7 @@ Node { end_line: 1, end_column: 23, }, - op: Bin( - And, - ), + op: And, right: Node { node: Compare( Compare { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_with_paren.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_with_paren.snap index 179afbde6..b370c6def 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_with_paren.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__binary_expr_with_paren.snap @@ -23,9 +23,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Mul, - ), + op: Mul, right: Node { node: Paren( ParenExpr { @@ -47,9 +45,7 @@ Node { end_line: 1, end_column: 4, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { @@ -89,9 +85,7 @@ Node { end_line: 1, end_column: 7, }, - op: Bin( - Sub, - ), + op: Sub, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__dict_comp_expr.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__dict_comp_expr.snap index 47a0c8716..6ee12cdb1 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__dict_comp_expr.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__dict_comp_expr.snap @@ -57,9 +57,7 @@ Node { end_line: 1, end_column: 5, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_0.snap index 98eef0b07..6c6715bc5 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_0.snap @@ -23,9 +23,7 @@ Node { end_line: 1, end_column: 2, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_1.snap index fa0105b3e..5a29b6407 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_1.snap @@ -26,9 +26,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_2.snap index 405b5f0e0..c353720ce 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__expr_with_paren_2.snap @@ -23,9 +23,7 @@ Node { end_line: 1, end_column: 2, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__line_continue.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__line_continue.snap index f45491884..a563e4cd8 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__line_continue.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__line_continue.snap @@ -20,9 +20,7 @@ Node { end_line: 1, end_column: 1, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__list_comp_expr_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__list_comp_expr_0.snap index 9e0d2a633..c6f7cc855 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__list_comp_expr_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__list_comp_expr_0.snap @@ -31,9 +31,7 @@ Node { end_line: 1, end_column: 2, }, - op: Bin( - Pow, - ), + op: Pow, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_1.snap index d52a567e1..a5f7197a3 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_1.snap @@ -66,9 +66,7 @@ Node { end_line: 1, end_column: 11, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_3.snap index 9bdc33aff..1116355bb 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_3.snap @@ -23,9 +23,7 @@ Node { end_line: 1, end_column: 3, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: Identifier( Identifier { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_6.snap index 5d1e2bbf0..b848314b7 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__logic_expr_6.snap @@ -29,9 +29,7 @@ Node { end_line: 1, end_column: 9, }, - op: Bin( - Or, - ), + op: Or, right: Node { node: Binary( BinaryExpr { @@ -89,9 +87,7 @@ Node { end_line: 1, end_column: 32, }, - op: Bin( - And, - ), + op: And, right: Node { node: Compare( Compare { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_0.snap index 91caf5d34..9de6c12ec 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_0.snap @@ -29,9 +29,7 @@ Node { end_line: 1, end_column: 6, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_1.snap index cf0d73a0d..5fa01f670 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__parse_joined_string_1.snap @@ -51,9 +51,7 @@ Node { end_line: 1, end_column: 7, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__quant_expr_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__quant_expr_2.snap index 7910878c3..e969f0cc3 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__quant_expr_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__quant_expr_2.snap @@ -78,9 +78,7 @@ Node { end_line: 1, end_column: 22, }, - op: Bin( - Add, - ), + op: Add, right: Node { node: NumberLit( NumberLit { diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_1.snap index bd86a14bf..7b8712908 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 3 expression: "crate::tests::parsing_file_string(\"testdata/assert-01.k\")" --- { @@ -12,27 +11,23 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-01.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-01.k", - "line": 1, - "column": 7, - "end_line": 1, - "end_column": 8 + "test": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } }, - "if_cond": null, - "msg": null - } + "filename": "assert-01.k", + "line": 1, + "column": 7, + "end_line": 1, + "end_column": 8 + }, + "if_cond": null, + "msg": null }, "filename": "assert-01.k", "line": 1, @@ -43,40 +38,34 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-01.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } - } - }, - "filename": "assert-01.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 8 + "test": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 + } + }, + "filename": "assert-01.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 8 + }, + "if_cond": null, + "msg": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"msg\"", + "value": "msg" }, - "if_cond": null, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"msg\"", - "value": "msg" - } - }, - "filename": "assert-01.k", - "line": 2, - "column": 10, - "end_line": 2, - "end_column": 15 - } + "filename": "assert-01.k", + "line": 2, + "column": 10, + "end_line": 2, + "end_column": 15 } }, "filename": "assert-01.k", @@ -88,23 +77,19 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-01.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } - }, - "filename": "assert-01.k", - "line": 3, - "column": 7, - "end_line": 3, - "end_column": 11 + "test": { + "node": { + "type": "NameConstantLit", + "value": "True" }, - "if_cond": null, - "msg": null - } + "filename": "assert-01.k", + "line": 3, + "column": 7, + "end_line": 3, + "end_column": 11 + }, + "if_cond": null, + "msg": null }, "filename": "assert-01.k", "line": 3, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_2.snap index cdffc87a4..e24e18208 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_2.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 4 expression: "crate::tests::parsing_file_string(\"testdata/assert-02.k\")" --- { @@ -12,23 +11,19 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-02.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } - }, - "filename": "assert-02.k", - "line": 1, - "column": 7, - "end_line": 1, - "end_column": 11 + "test": { + "node": { + "type": "NameConstantLit", + "value": "True" }, - "if_cond": null, - "msg": null - } + "filename": "assert-02.k", + "line": 1, + "column": 7, + "end_line": 1, + "end_column": 11 + }, + "if_cond": null, + "msg": null }, "filename": "assert-02.k", "line": 1, @@ -39,61 +34,53 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-02.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-02.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 8 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-02.k", - "line": 2, - "column": 12, - "end_line": 2, - "end_column": 13 + "test": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "assert-02.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 8 + }, + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 } - ] + }, + "filename": "assert-02.k", + "line": 2, + "column": 12, + "end_line": 2, + "end_column": 13 } - }, - "filename": "assert-02.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 13 + ] }, - "if_cond": null, - "msg": null - } + "filename": "assert-02.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 13 + }, + "if_cond": null, + "msg": null }, "filename": "assert-02.k", "line": 2, @@ -104,47 +91,43 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-02.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "_x", - "filename": "assert-02.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 2 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "assert-02.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 2 - } - ], - "value": { + "targets": [ + { "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } + "names": [ + { + "node": "_x", + "filename": "assert-02.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 2 + } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "assert-02.k", "line": 3, - "column": 5, + "column": 0, "end_line": 3, - "end_column": 16 + "end_column": 2 + } + ], + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" }, - "ty": null - } + "filename": "assert-02.k", + "line": 3, + "column": 5, + "end_line": 3, + "end_column": 16 + }, + "ty": null }, "filename": "assert-02.k", "line": 3, @@ -155,66 +138,58 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-02.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_x", - "filename": "assert-02.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "assert-02.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 9 - }, - "ops": [ - "Eq" - ], - "comparators": [ + "test": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } - }, + "node": "_x", "filename": "assert-02.k", "line": 4, - "column": 13, + "column": 7, "end_line": 4, - "end_column": 24 + "end_column": 9 } - ] - } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "assert-02.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 9 }, - "filename": "assert-02.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 24 + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" + }, + "filename": "assert-02.k", + "line": 4, + "column": 13, + "end_line": 4, + "end_column": 24 + } + ] }, - "if_cond": null, - "msg": null - } + "filename": "assert-02.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 24 + }, + "if_cond": null, + "msg": null }, "filename": "assert-02.k", "line": 4, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_3.snap index a8957b89a..59faefaf9 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_3.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 5 expression: "crate::tests::parsing_file_string(\"testdata/assert-03.k\")" --- { @@ -12,293 +11,257 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-03.k\")" { "node": { "type": "If", - "data": { - "body": [ - { - "node": { - "type": "Assert", - "data": { - "test": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } - }, - "filename": "assert-03.k", - "line": 2, - "column": 11, - "end_line": 2, - "end_column": 15 - }, - "if_cond": null, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"Error messgae\"", - "value": "Error messgae" - } - }, - "filename": "assert-03.k", - "line": 2, - "column": 17, - "end_line": 2, - "end_column": 32 - } - } + "body": [ + { + "node": { + "type": "Assert", + "test": { + "node": { + "type": "NameConstantLit", + "value": "True" + }, + "filename": "assert-03.k", + "line": 2, + "column": 11, + "end_line": 2, + "end_column": 15 }, - "filename": "assert-03.k", - "line": 2, - "column": 4, - "end_line": 2, - "end_column": 32 + "if_cond": null, + "msg": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"Error messgae\"", + "value": "Error messgae" + }, + "filename": "assert-03.k", + "line": 2, + "column": 17, + "end_line": 2, + "end_column": 32 + } }, - { - "node": { - "type": "Assert", - "data": { - "test": { + "filename": "assert-03.k", + "line": 2, + "column": 4, + "end_line": 2, + "end_column": 32 + }, + { + "node": { + "type": "Assert", + "test": { + "node": { + "type": "Compare", + "left": { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-03.k", - "line": 3, - "column": 11, - "end_line": 3, - "end_column": 12 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-03.k", - "line": 3, - "column": 16, - "end_line": 3, - "end_column": 17 - } - ] + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 } }, "filename": "assert-03.k", "line": 3, "column": 11, "end_line": 3, - "end_column": 17 + "end_column": 12 }, - "if_cond": null, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"\"", - "value": "" - } - }, - "filename": "assert-03.k", - "line": 3, - "column": 19, - "end_line": 3, - "end_column": 21 - } - } - }, - "filename": "assert-03.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 21 - }, - { - "node": { - "type": "Assign", - "data": { - "targets": [ + "ops": [ + "Eq" + ], + "comparators": [ { "node": { - "names": [ - { - "node": "_x", - "filename": "assert-03.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Store" + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } }, "filename": "assert-03.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 6 + "line": 3, + "column": 16, + "end_line": 3, + "end_column": 17 } - ], - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" + ] + }, + "filename": "assert-03.k", + "line": 3, + "column": 11, + "end_line": 3, + "end_column": 17 + }, + "if_cond": null, + "msg": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"\"", + "value": "" + }, + "filename": "assert-03.k", + "line": 3, + "column": 19, + "end_line": 3, + "end_column": 21 + } + }, + "filename": "assert-03.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 21 + }, + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ + { + "node": "_x", + "filename": "assert-03.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 6 } - }, - "filename": "assert-03.k", - "line": 4, - "column": 9, - "end_line": 4, - "end_column": 20 + ], + "pkgpath": "", + "ctx": "Store" }, - "ty": null + "filename": "assert-03.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 6 } + ], + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" + }, + "filename": "assert-03.k", + "line": 4, + "column": 9, + "end_line": 4, + "end_column": 20 }, - "filename": "assert-03.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 20 + "ty": null }, - { - "node": { - "type": "Assert", - "data": { - "test": { + "filename": "assert-03.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 20 + }, + { + "node": { + "type": "Assert", + "test": { + "node": { + "type": "Compare", + "left": { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_x", - "filename": "assert-03.k", - "line": 5, - "column": 11, - "end_line": 5, - "end_column": 13 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "_x", "filename": "assert-03.k", "line": 5, "column": 11, "end_line": 5, "end_column": 13 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } - }, - "filename": "assert-03.k", - "line": 5, - "column": 17, - "end_line": 5, - "end_column": 28 - } - ] - } + } + ], + "pkgpath": "", + "ctx": "Load" }, "filename": "assert-03.k", "line": 5, "column": 11, "end_line": 5, - "end_column": 28 + "end_column": 13 }, - "if_cond": null, - "msg": null - } + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" + }, + "filename": "assert-03.k", + "line": 5, + "column": 17, + "end_line": 5, + "end_column": 28 + } + ] + }, + "filename": "assert-03.k", + "line": 5, + "column": 11, + "end_line": 5, + "end_column": 28 }, - "filename": "assert-03.k", - "line": 5, - "column": 4, - "end_line": 5, - "end_column": 28 - } - ], - "cond": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } + "if_cond": null, + "msg": null }, "filename": "assert-03.k", - "line": 1, - "column": 3, - "end_line": 1, - "end_column": 7 + "line": 5, + "column": 4, + "end_line": 5, + "end_column": 28 + } + ], + "cond": { + "node": { + "type": "NameConstantLit", + "value": "True" }, - "orelse": [ - { - "node": { - "type": "Assert", - "data": { - "test": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "False" - } - }, - "filename": "assert-03.k", - "line": 7, - "column": 11, - "end_line": 7, - "end_column": 16 - }, - "if_cond": null, - "msg": null - } + "filename": "assert-03.k", + "line": 1, + "column": 3, + "end_line": 1, + "end_column": 7 + }, + "orelse": [ + { + "node": { + "type": "Assert", + "test": { + "node": { + "type": "NameConstantLit", + "value": "False" + }, + "filename": "assert-03.k", + "line": 7, + "column": 11, + "end_line": 7, + "end_column": 16 }, - "filename": "assert-03.k", - "line": 7, - "column": 4, - "end_line": 7, - "end_column": 16 - } - ] - } + "if_cond": null, + "msg": null + }, + "filename": "assert-03.k", + "line": 7, + "column": 4, + "end_line": 7, + "end_column": 16 + } + ] }, "filename": "assert-03.k", "line": 1, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_0.snap index 2e912c805..0495e654d 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_0.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 6 expression: "crate::tests::parsing_file_string(\"testdata/assert-if-0.k\")" --- { @@ -12,23 +11,19 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-0.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } - }, - "filename": "assert-if-0.k", - "line": 1, - "column": 7, - "end_line": 1, - "end_column": 11 + "test": { + "node": { + "type": "NameConstantLit", + "value": "True" }, - "if_cond": null, - "msg": null - } + "filename": "assert-if-0.k", + "line": 1, + "column": 7, + "end_line": 1, + "end_column": 11 + }, + "if_cond": null, + "msg": null }, "filename": "assert-if-0.k", "line": 1, @@ -39,73 +34,63 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-0.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-if-0.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 8 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-if-0.k", - "line": 2, - "column": 12, - "end_line": 2, - "end_column": 13 + "test": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "assert-if-0.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 8 + }, + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 } - ] + }, + "filename": "assert-if-0.k", + "line": 2, + "column": 12, + "end_line": 2, + "end_column": 13 } - }, - "filename": "assert-if-0.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 13 + ] }, - "if_cond": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } - }, - "filename": "assert-if-0.k", - "line": 2, - "column": 17, - "end_line": 2, - "end_column": 21 + "filename": "assert-if-0.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 13 + }, + "if_cond": { + "node": { + "type": "NameConstantLit", + "value": "True" }, - "msg": null - } + "filename": "assert-if-0.k", + "line": 2, + "column": 17, + "end_line": 2, + "end_column": 21 + }, + "msg": null }, "filename": "assert-if-0.k", "line": 2, @@ -116,47 +101,43 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-0.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "_x", - "filename": "assert-if-0.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 2 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "assert-if-0.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 2 - } - ], - "value": { + "targets": [ + { "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } + "names": [ + { + "node": "_x", + "filename": "assert-if-0.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 2 + } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "assert-if-0.k", "line": 3, - "column": 5, + "column": 0, "end_line": 3, - "end_column": 16 + "end_column": 2 + } + ], + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" }, - "ty": null - } + "filename": "assert-if-0.k", + "line": 3, + "column": 5, + "end_line": 3, + "end_column": 16 + }, + "ty": null }, "filename": "assert-if-0.k", "line": 3, @@ -167,102 +148,90 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-0.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_x", - "filename": "assert-if-0.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "assert-if-0.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 9 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } - }, - "filename": "assert-if-0.k", - "line": 4, - "column": 13, - "end_line": 4, - "end_column": 24 - } - ] - } - }, - "filename": "assert-if-0.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 24 - }, - "if_cond": { - "node": { - "type": "Identifier", - "data": { + "test": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", "names": [ { "node": "_x", "filename": "assert-if-0.k", "line": 4, - "column": 28, + "column": 7, "end_line": 4, - "end_column": 30 + "end_column": 9 } ], "pkgpath": "", "ctx": "Load" - } + }, + "filename": "assert-if-0.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 9 }, - "filename": "assert-if-0.k", - "line": 4, - "column": 28, - "end_line": 4, - "end_column": 30 + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" + }, + "filename": "assert-if-0.k", + "line": 4, + "column": 13, + "end_line": 4, + "end_column": 24 + } + ] }, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"_x need to be 'good case'\"", - "value": "_x need to be 'good case'" + "filename": "assert-if-0.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 24 + }, + "if_cond": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "_x", + "filename": "assert-if-0.k", + "line": 4, + "column": 28, + "end_line": 4, + "end_column": 30 } - }, - "filename": "assert-if-0.k", - "line": 4, - "column": 32, - "end_line": 4, - "end_column": 59 - } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "assert-if-0.k", + "line": 4, + "column": 28, + "end_line": 4, + "end_column": 30 + }, + "msg": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"_x need to be 'good case'\"", + "value": "_x need to be 'good case'" + }, + "filename": "assert-if-0.k", + "line": 4, + "column": 32, + "end_line": 4, + "end_column": 59 } }, "filename": "assert-if-0.k", diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_1.snap index 6151e0d55..110f9d077 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 7 expression: "crate::tests::parsing_file_string(\"testdata/assert-if-1.k\")" --- { @@ -12,35 +11,29 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-1.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } - }, - "filename": "assert-if-1.k", - "line": 1, - "column": 7, - "end_line": 1, - "end_column": 11 + "test": { + "node": { + "type": "NameConstantLit", + "value": "True" }, - "if_cond": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "False" - } - }, - "filename": "assert-if-1.k", - "line": 1, - "column": 15, - "end_line": 1, - "end_column": 20 + "filename": "assert-if-1.k", + "line": 1, + "column": 7, + "end_line": 1, + "end_column": 11 + }, + "if_cond": { + "node": { + "type": "NameConstantLit", + "value": "False" }, - "msg": null - } + "filename": "assert-if-1.k", + "line": 1, + "column": 15, + "end_line": 1, + "end_column": 20 + }, + "msg": null }, "filename": "assert-if-1.k", "line": 1, @@ -51,73 +44,63 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-1.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-if-1.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 8 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-if-1.k", - "line": 2, - "column": 12, - "end_line": 2, - "end_column": 13 + "test": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "assert-if-1.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 8 + }, + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 } - ] + }, + "filename": "assert-if-1.k", + "line": 2, + "column": 12, + "end_line": 2, + "end_column": 13 } - }, - "filename": "assert-if-1.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 13 + ] }, - "if_cond": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "False" - } - }, - "filename": "assert-if-1.k", - "line": 2, - "column": 17, - "end_line": 2, - "end_column": 22 + "filename": "assert-if-1.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 13 + }, + "if_cond": { + "node": { + "type": "NameConstantLit", + "value": "False" }, - "msg": null - } + "filename": "assert-if-1.k", + "line": 2, + "column": 17, + "end_line": 2, + "end_column": 22 + }, + "msg": null }, "filename": "assert-if-1.k", "line": 2, @@ -128,47 +111,43 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-1.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "_x", - "filename": "assert-if-1.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 2 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "assert-if-1.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 2 - } - ], - "value": { + "targets": [ + { "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } + "names": [ + { + "node": "_x", + "filename": "assert-if-1.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 2 + } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "assert-if-1.k", "line": 3, - "column": 5, + "column": 0, "end_line": 3, - "end_column": 16 + "end_column": 2 + } + ], + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" }, - "ty": null - } + "filename": "assert-if-1.k", + "line": 3, + "column": 5, + "end_line": 3, + "end_column": 16 + }, + "ty": null }, "filename": "assert-if-1.k", "line": 3, @@ -179,115 +158,101 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-1.k\")" { "node": { "type": "Assert", - "data": { - "test": { - "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_x", - "filename": "assert-if-1.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 9 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "assert-if-1.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 9 - }, - "ops": [ - "Eq" - ], - "comparators": [ + "test": { + "node": { + "type": "Compare", + "left": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } - }, + "node": "_x", "filename": "assert-if-1.k", "line": 4, - "column": 13, + "column": 7, "end_line": 4, - "end_column": 24 + "end_column": 9 } - ] - } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "assert-if-1.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 9 }, - "filename": "assert-if-1.k", - "line": 4, - "column": 7, - "end_line": 4, - "end_column": 24 - }, - "if_cond": { - "node": { - "type": "Unary", - "data": { - "op": "Not", - "operand": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_x", - "filename": "assert-if-1.k", - "line": 4, - "column": 32, - "end_line": 4, - "end_column": 34 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "assert-if-1.k", - "line": 4, - "column": 32, - "end_line": 4, - "end_column": 34 - } + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" + }, + "filename": "assert-if-1.k", + "line": 4, + "column": 13, + "end_line": 4, + "end_column": 24 } - }, - "filename": "assert-if-1.k", - "line": 4, - "column": 28, - "end_line": 4, - "end_column": 34 + ] }, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"_x need to be 'good case'\"", - "value": "_x need to be 'good case'" - } - }, - "filename": "assert-if-1.k", - "line": 4, - "column": 36, - "end_line": 4, - "end_column": 63 - } + "filename": "assert-if-1.k", + "line": 4, + "column": 7, + "end_line": 4, + "end_column": 24 + }, + "if_cond": { + "node": { + "type": "Unary", + "op": "Not", + "operand": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "_x", + "filename": "assert-if-1.k", + "line": 4, + "column": 32, + "end_line": 4, + "end_column": 34 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "assert-if-1.k", + "line": 4, + "column": 32, + "end_line": 4, + "end_column": 34 + } + }, + "filename": "assert-if-1.k", + "line": 4, + "column": 28, + "end_line": 4, + "end_column": 34 + }, + "msg": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"_x need to be 'good case'\"", + "value": "_x need to be 'good case'" + }, + "filename": "assert-if-1.k", + "line": 4, + "column": 36, + "end_line": 4, + "end_column": 63 } }, "filename": "assert-if-1.k", diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_2.snap index 62daddc4d..592458159 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assert_if_2.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 8 expression: "crate::tests::parsing_file_string(\"testdata/assert-if-2.k\")" --- { @@ -12,315 +11,279 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-2.k\")" { "node": { "type": "Schema", - "data": { - "doc": null, - "name": { - "node": "Data", - "filename": "assert-if-2.k", - "line": 1, - "column": 7, - "end_line": 1, - "end_column": 11 - }, - "parent_name": null, - "for_host_name": null, - "is_mixin": false, - "is_protocol": false, - "args": null, - "mixins": [], - "body": [ - { - "node": { - "type": "Assert", - "data": { - "test": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } - }, - "filename": "assert-if-2.k", - "line": 2, - "column": 11, - "end_line": 2, - "end_column": 15 - }, - "if_cond": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "False" - } - }, - "filename": "assert-if-2.k", - "line": 2, - "column": 19, - "end_line": 2, - "end_column": 24 - }, - "msg": null - } + "doc": null, + "name": { + "node": "Data", + "filename": "assert-if-2.k", + "line": 1, + "column": 7, + "end_line": 1, + "end_column": 11 + }, + "parent_name": null, + "for_host_name": null, + "is_mixin": false, + "is_protocol": false, + "args": null, + "mixins": [], + "body": [ + { + "node": { + "type": "Assert", + "test": { + "node": { + "type": "NameConstantLit", + "value": "True" + }, + "filename": "assert-if-2.k", + "line": 2, + "column": 11, + "end_line": 2, + "end_column": 15 }, - "filename": "assert-if-2.k", - "line": 2, - "column": 4, - "end_line": 2, - "end_column": 24 + "if_cond": { + "node": { + "type": "NameConstantLit", + "value": "False" + }, + "filename": "assert-if-2.k", + "line": 2, + "column": 19, + "end_line": 2, + "end_column": 24 + }, + "msg": null }, - { - "node": { - "type": "Assert", - "data": { - "test": { + "filename": "assert-if-2.k", + "line": 2, + "column": 4, + "end_line": 2, + "end_column": 24 + }, + { + "node": { + "type": "Assert", + "test": { + "node": { + "type": "Compare", + "left": { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-if-2.k", - "line": 3, - "column": 11, - "end_line": 3, - "end_column": 12 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assert-if-2.k", - "line": 3, - "column": 16, - "end_line": 3, - "end_column": 17 - } - ] + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 } }, "filename": "assert-if-2.k", "line": 3, "column": 11, "end_line": 3, - "end_column": 17 + "end_column": 12 }, - "if_cond": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "False" - } - }, - "filename": "assert-if-2.k", - "line": 3, - "column": 21, - "end_line": 3, - "end_column": 26 - }, - "msg": null - } - }, - "filename": "assert-if-2.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 26 - }, - { - "node": { - "type": "Assign", - "data": { - "targets": [ + "ops": [ + "Eq" + ], + "comparators": [ { "node": { - "names": [ - { - "node": "_x", - "filename": "assert-if-2.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Store" + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } }, "filename": "assert-if-2.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 6 + "line": 3, + "column": 16, + "end_line": 3, + "end_column": 17 } - ], - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" + ] + }, + "filename": "assert-if-2.k", + "line": 3, + "column": 11, + "end_line": 3, + "end_column": 17 + }, + "if_cond": { + "node": { + "type": "NameConstantLit", + "value": "False" + }, + "filename": "assert-if-2.k", + "line": 3, + "column": 21, + "end_line": 3, + "end_column": 26 + }, + "msg": null + }, + "filename": "assert-if-2.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 26 + }, + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ + { + "node": "_x", + "filename": "assert-if-2.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 6 } - }, - "filename": "assert-if-2.k", - "line": 4, - "column": 9, - "end_line": 4, - "end_column": 20 + ], + "pkgpath": "", + "ctx": "Store" }, - "ty": null + "filename": "assert-if-2.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 6 } + ], + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" + }, + "filename": "assert-if-2.k", + "line": 4, + "column": 9, + "end_line": 4, + "end_column": 20 }, - "filename": "assert-if-2.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 20 + "ty": null }, - { - "node": { - "type": "Assert", - "data": { - "test": { + "filename": "assert-if-2.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 20 + }, + { + "node": { + "type": "Assert", + "test": { + "node": { + "type": "Compare", + "left": { "node": { - "type": "Compare", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_x", - "filename": "assert-if-2.k", - "line": 5, - "column": 11, - "end_line": 5, - "end_column": 13 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "_x", "filename": "assert-if-2.k", "line": 5, "column": 11, "end_line": 5, "end_column": 13 - }, - "ops": [ - "Eq" - ], - "comparators": [ - { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"good case\"", - "value": "good case" - } - }, - "filename": "assert-if-2.k", - "line": 5, - "column": 17, - "end_line": 5, - "end_column": 28 - } - ] - } + } + ], + "pkgpath": "", + "ctx": "Load" }, "filename": "assert-if-2.k", "line": 5, "column": 11, "end_line": 5, - "end_column": 28 + "end_column": 13 }, - "if_cond": { + "ops": [ + "Eq" + ], + "comparators": [ + { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"good case\"", + "value": "good case" + }, + "filename": "assert-if-2.k", + "line": 5, + "column": 17, + "end_line": 5, + "end_column": 28 + } + ] + }, + "filename": "assert-if-2.k", + "line": 5, + "column": 11, + "end_line": 5, + "end_column": 28 + }, + "if_cond": { + "node": { + "type": "Unary", + "op": "Not", + "operand": { "node": { - "type": "Unary", - "data": { - "op": "Not", - "operand": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_x", - "filename": "assert-if-2.k", - "line": 5, - "column": 36, - "end_line": 5, - "end_column": 38 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "_x", "filename": "assert-if-2.k", "line": 5, "column": 36, "end_line": 5, "end_column": 38 } - } + ], + "pkgpath": "", + "ctx": "Load" }, "filename": "assert-if-2.k", "line": 5, - "column": 32, + "column": 36, "end_line": 5, "end_column": 38 - }, - "msg": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"_x need to be 'good case'\"", - "value": "_x need to be 'good case'" - } - }, - "filename": "assert-if-2.k", - "line": 5, - "column": 40, - "end_line": 5, - "end_column": 67 } - } + }, + "filename": "assert-if-2.k", + "line": 5, + "column": 32, + "end_line": 5, + "end_column": 38 }, - "filename": "assert-if-2.k", - "line": 5, - "column": 4, - "end_line": 5, - "end_column": 67 - } - ], - "decorators": [], - "checks": [], - "index_signature": null - } + "msg": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"_x need to be 'good case'\"", + "value": "_x need to be 'good case'" + }, + "filename": "assert-if-2.k", + "line": 5, + "column": 40, + "end_line": 5, + "end_column": 67 + } + }, + "filename": "assert-if-2.k", + "line": 5, + "column": 4, + "end_line": 5, + "end_column": 67 + } + ], + "decorators": [], + "checks": [], + "index_signature": null }, "filename": "assert-if-2.k", "line": 1, @@ -331,80 +294,74 @@ expression: "crate::tests::parsing_file_string(\"testdata/assert-if-2.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { + "targets": [ + { + "node": { + "names": [ + { + "node": "data", + "filename": "assert-if-2.k", + "line": 7, + "column": 0, + "end_line": 7, + "end_column": 4 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "assert-if-2.k", + "line": 7, + "column": 0, + "end_line": 7, + "end_column": 4 + } + ], + "value": { + "node": { + "type": "Schema", + "name": { "node": { "names": [ { - "node": "data", + "node": "Data", "filename": "assert-if-2.k", "line": 7, - "column": 0, + "column": 7, "end_line": 7, - "end_column": 4 + "end_column": 11 } ], "pkgpath": "", - "ctx": "Store" + "ctx": "Load" }, "filename": "assert-if-2.k", "line": 7, - "column": 0, + "column": 7, "end_line": 7, - "end_column": 4 - } - ], - "value": { - "node": { - "type": "Schema", - "data": { - "name": { - "node": { - "names": [ - { - "node": "Data", - "filename": "assert-if-2.k", - "line": 7, - "column": 7, - "end_line": 7, - "end_column": 11 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "assert-if-2.k", - "line": 7, - "column": 7, - "end_line": 7, - "end_column": 11 - }, - "args": [], - "kwargs": [], - "config": { - "node": { - "type": "Config", - "data": { - "items": [] - } - }, - "filename": "assert-if-2.k", - "line": 7, - "column": 12, - "end_line": 7, - "end_column": 14 - } - } + "end_column": 11 }, - "filename": "assert-if-2.k", - "line": 7, - "column": 7, - "end_line": 7, - "end_column": 14 + "args": [], + "kwargs": [], + "config": { + "node": { + "type": "Config", + "items": [] + }, + "filename": "assert-if-2.k", + "line": 7, + "column": 12, + "end_line": 7, + "end_column": 14 + } }, - "ty": null - } + "filename": "assert-if-2.k", + "line": 7, + "column": 7, + "end_line": 7, + "end_column": 14 + }, + "ty": null }, "filename": "assert-if-2.k", "line": 7, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assign_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assign_1.snap index a6c13090b..56467d8a7 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assign_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__assign_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 9 expression: "crate::tests::parsing_file_string(\"testdata/assign-01.k\")" --- { @@ -12,49 +11,45 @@ expression: "crate::tests::parsing_file_string(\"testdata/assign-01.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "a", - "filename": "assign-01.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "assign-01.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 + "names": [ + { + "node": "a", + "filename": "assign-01.k", + "line": 1, + "column": 0, + "end_line": 1, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "assign-01.k", "line": 1, - "column": 2, + "column": 0, "end_line": 1, - "end_column": 3 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } }, - "ty": null - } + "filename": "assign-01.k", + "line": 1, + "column": 2, + "end_line": 1, + "end_column": 3 + }, + "ty": null }, "filename": "assign-01.k", "line": 1, @@ -65,82 +60,71 @@ expression: "crate::tests::parsing_file_string(\"testdata/assign-01.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "b", - "filename": "assign-01.k", - "line": 2, - "column": 0, - "end_line": 2, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "assign-01.k", - "line": 2, - "column": 0, - "end_line": 2, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "Binary", - "data": { - "left": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } - } - }, - "filename": "assign-01.k", - "line": 2, - "column": 4, - "end_line": 2, - "end_column": 5 - }, - "op": { - "type": "Bin", - "data": "Add" - }, - "right": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } - } - }, + "names": [ + { + "node": "b", "filename": "assign-01.k", "line": 2, - "column": 8, + "column": 0, "end_line": 2, - "end_column": 9 + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "assign-01.k", "line": 2, - "column": 4, + "column": 0, "end_line": 2, - "end_column": 9 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "Binary", + "left": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "assign-01.k", + "line": 2, + "column": 4, + "end_line": 2, + "end_column": 5 + }, + "op": "Add", + "right": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 + } + }, + "filename": "assign-01.k", + "line": 2, + "column": 8, + "end_line": 2, + "end_column": 9 + } }, - "ty": null - } + "filename": "assign-01.k", + "line": 2, + "column": 4, + "end_line": 2, + "end_column": 9 + }, + "ty": null }, "filename": "assign-01.k", "line": 2, @@ -151,115 +135,97 @@ expression: "crate::tests::parsing_file_string(\"testdata/assign-01.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { + "targets": [ + { + "node": { + "names": [ + { + "node": "c", + "filename": "assign-01.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 1 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "assign-01.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 1 + } + ], + "value": { + "node": { + "type": "Binary", + "left": { "node": { - "names": [ - { - "node": "c", - "filename": "assign-01.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 + } }, "filename": "assign-01.k", "line": 3, - "column": 0, + "column": 4, "end_line": 3, - "end_column": 1 - } - ], - "value": { - "node": { - "type": "Binary", - "data": { + "end_column": 5 + }, + "op": "Add", + "right": { + "node": { + "type": "Binary", "left": { "node": { "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 } }, "filename": "assign-01.k", "line": 3, - "column": 4, + "column": 8, "end_line": 3, - "end_column": 5 - }, - "op": { - "type": "Bin", - "data": "Add" + "end_column": 9 }, + "op": "Mul", "right": { "node": { - "type": "Binary", - "data": { - "left": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } - } - }, - "filename": "assign-01.k", - "line": 3, - "column": 8, - "end_line": 3, - "end_column": 9 - }, - "op": { - "type": "Bin", - "data": "Mul" - }, - "right": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 3 - } - } - }, - "filename": "assign-01.k", - "line": 3, - "column": 10, - "end_line": 3, - "end_column": 11 - } + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 3 } }, "filename": "assign-01.k", "line": 3, - "column": 8, + "column": 10, "end_line": 3, "end_column": 11 } - } - }, - "filename": "assign-01.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 11 + }, + "filename": "assign-01.k", + "line": 3, + "column": 8, + "end_line": 3, + "end_column": 11 + } }, - "ty": null - } + "filename": "assign-01.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 11 + }, + "ty": null }, "filename": "assign-01.k", "line": 3, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_1.snap index ea80bf9d6..af4a785c8 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 10 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-01.k\")" --- { @@ -12,45 +11,41 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-01.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "config", - "filename": "config_expr-01.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "config_expr-01.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 6 - } - ], - "value": { + "targets": [ + { "node": { - "type": "Config", - "data": { - "items": [] - } + "names": [ + { + "node": "config", + "filename": "config_expr-01.k", + "line": 1, + "column": 0, + "end_line": 1, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "config_expr-01.k", "line": 1, - "column": 9, - "end_line": 2, - "end_column": 1 + "column": 0, + "end_line": 1, + "end_column": 6 + } + ], + "value": { + "node": { + "type": "Config", + "items": [] }, - "ty": null - } + "filename": "config_expr-01.k", + "line": 1, + "column": 9, + "end_line": 2, + "end_column": 1 + }, + "ty": null }, "filename": "config_expr-01.k", "line": 1, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_2.snap index ad1df6d7b..c0f8a8faf 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_2.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 11 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-02.k\")" --- { @@ -12,150 +11,138 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-02.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "config", + "targets": [ + { + "node": { + "names": [ + { + "node": "config", + "filename": "config_expr-02.k", + "line": 1, + "column": 0, + "end_line": 1, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "config_expr-02.k", + "line": 1, + "column": 0, + "end_line": 1, + "end_column": 6 + } + ], + "value": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "k1", + "filename": "config_expr-02.k", + "line": 2, + "column": 4, + "end_line": 2, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" + }, "filename": "config_expr-02.k", - "line": 1, - "column": 0, - "end_line": 1, + "line": 2, + "column": 4, + "end_line": 2, "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "config_expr-02.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 6 - } - ], - "value": { - "node": { - "type": "Config", - "data": { - "items": [ - { + }, + "value": { "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "k1", - "filename": "config_expr-02.k", - "line": 2, - "column": 4, - "end_line": 2, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-02.k", - "line": 2, - "column": 4, - "end_line": 2, - "end_column": 6 - }, + "type": "NumberLit", + "binary_suffix": null, "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 111 - } - } - }, - "filename": "config_expr-02.k", - "line": 2, - "column": 9, - "end_line": 2, - "end_column": 12 - }, - "operation": "Override", - "insert_index": -1 + "type": "Int", + "value": 111 + } }, "filename": "config_expr-02.k", "line": 2, - "column": 4, + "column": 9, "end_line": 2, "end_column": 12 }, - { + "operation": "Override", + "insert_index": -1 + }, + "filename": "config_expr-02.k", + "line": 2, + "column": 4, + "end_line": 2, + "end_column": 12 + }, + { + "node": { + "key": { "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "k2", - "filename": "config_expr-02.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-02.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 6 - }, - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 222 - } - } - }, - "filename": "config_expr-02.k", - "line": 3, - "column": 9, - "end_line": 3, - "end_column": 12 - }, - "operation": "Override", - "insert_index": -1 + "type": "Identifier", + "names": [ + { + "node": "k2", + "filename": "config_expr-02.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" }, "filename": "config_expr-02.k", "line": 3, "column": 4, "end_line": 3, + "end_column": 6 + }, + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 222 + } + }, + "filename": "config_expr-02.k", + "line": 3, + "column": 9, + "end_line": 3, "end_column": 12 - } - ] + }, + "operation": "Override", + "insert_index": -1 + }, + "filename": "config_expr-02.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 12 } - }, - "filename": "config_expr-02.k", - "line": 1, - "column": 9, - "end_line": 4, - "end_column": 1 + ] }, - "ty": null - } + "filename": "config_expr-02.k", + "line": 1, + "column": 9, + "end_line": 4, + "end_column": 1 + }, + "ty": null }, "filename": "config_expr-02.k", "line": 1, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_3.snap index b0662e8c1..c87d218f0 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_3.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 12 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-03.k\")" --- { @@ -12,472 +11,432 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-03.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "config", - "filename": "config_expr-03.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "config_expr-03.k", - "line": 3, - "column": 0, - "end_line": 3, - "end_column": 6 - } - ], - "value": { + "targets": [ + { "node": { - "type": "Config", - "data": { - "items": [ - { + "names": [ + { + "node": "config", + "filename": "config_expr-03.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "config_expr-03.k", + "line": 3, + "column": 0, + "end_line": 3, + "end_column": 6 + } + ], + "value": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": { "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "main", - "filename": "config_expr-03.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 8 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-03.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 8 - }, - "value": { - "node": { - "type": "Config", - "data": { - "items": [ - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "env", - "filename": "config_expr-03.k", - "line": 5, - "column": 8, - "end_line": 5, - "end_column": 11 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "main", + "filename": "config_expr-03.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 8 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 8 + }, + "value": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "env", "filename": "config_expr-03.k", "line": 5, "column": 8, "end_line": 5, "end_column": 11 - }, - "value": { + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 5, + "column": 8, + "end_line": 5, + "end_column": 11 + }, + "value": { + "node": { + "type": "List", + "elts": [ + { "node": { - "type": "List", - "data": { - "elts": [ - { - "node": { - "type": "Config", - "data": { - "items": [ + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "name", - "filename": "config_expr-03.k", - "line": 6, - "column": 13, - "end_line": 6, - "end_column": 17 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-03.k", - "line": 6, - "column": 13, - "end_line": 6, - "end_column": 17 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"ENV_1\"", - "value": "ENV_1" - } - }, - "filename": "config_expr-03.k", - "line": 6, - "column": 19, - "end_line": 6, - "end_column": 26 - }, - "operation": "Union", - "insert_index": -1 - }, + "node": "name", "filename": "config_expr-03.k", "line": 6, "column": 13, "end_line": 6, - "end_column": 26 - }, + "end_column": 17 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 6, + "column": 13, + "end_line": 6, + "end_column": 17 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"ENV_1\"", + "value": "ENV_1" + }, + "filename": "config_expr-03.k", + "line": 6, + "column": 19, + "end_line": 6, + "end_column": 26 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 6, + "column": 13, + "end_line": 6, + "end_column": 26 + }, + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "value", - "filename": "config_expr-03.k", - "line": 6, - "column": 28, - "end_line": 6, - "end_column": 33 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-03.k", - "line": 6, - "column": 28, - "end_line": 6, - "end_column": 33 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"1\"", - "value": "1" - } - }, - "filename": "config_expr-03.k", - "line": 6, - "column": 35, - "end_line": 6, - "end_column": 38 - }, - "operation": "Union", - "insert_index": -1 - }, + "node": "value", "filename": "config_expr-03.k", "line": 6, "column": 28, "end_line": 6, - "end_column": 38 + "end_column": 33 } - ] - } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 6, + "column": 28, + "end_line": 6, + "end_column": 33 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"1\"", + "value": "1" + }, + "filename": "config_expr-03.k", + "line": 6, + "column": 35, + "end_line": 6, + "end_column": 38 }, - "filename": "config_expr-03.k", - "line": 6, - "column": 12, - "end_line": 6, - "end_column": 39 - } - ], - "ctx": "Load" - } + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 6, + "column": 28, + "end_line": 6, + "end_column": 38 + } + ] }, "filename": "config_expr-03.k", - "line": 5, - "column": 13, - "end_line": 7, - "end_column": 9 - }, - "operation": "Union", - "insert_index": -1 - }, - "filename": "config_expr-03.k", - "line": 5, - "column": 8, - "end_line": 7, - "end_column": 9 - } - ] - } - }, - "filename": "config_expr-03.k", - "line": 4, - "column": 10, - "end_line": 8, - "end_column": 5 - }, - "operation": "Union", - "insert_index": -1 + "line": 6, + "column": 12, + "end_line": 6, + "end_column": 39 + } + ], + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 5, + "column": 13, + "end_line": 7, + "end_column": 9 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 5, + "column": 8, + "end_line": 7, + "end_column": 9 + } + ] }, "filename": "config_expr-03.k", "line": 4, - "column": 4, + "column": 10, "end_line": 8, "end_column": 5 }, - { + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 4, + "column": 4, + "end_line": 8, + "end_column": 5 + }, + { + "node": { + "key": { "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "main", - "filename": "config_expr-03.k", - "line": 9, - "column": 4, - "end_line": 9, - "end_column": 8 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-03.k", - "line": 9, - "column": 4, - "end_line": 9, - "end_column": 8 - }, - "value": { - "node": { - "type": "Config", - "data": { - "items": [ - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "env", - "filename": "config_expr-03.k", - "line": 10, - "column": 8, - "end_line": 10, - "end_column": 11 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "type": "Identifier", + "names": [ + { + "node": "main", + "filename": "config_expr-03.k", + "line": 9, + "column": 4, + "end_line": 9, + "end_column": 8 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 9, + "column": 4, + "end_line": 9, + "end_column": 8 + }, + "value": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "env", "filename": "config_expr-03.k", "line": 10, "column": 8, "end_line": 10, "end_column": 11 - }, - "value": { + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 10, + "column": 8, + "end_line": 10, + "end_column": 11 + }, + "value": { + "node": { + "type": "List", + "elts": [ + { "node": { - "type": "List", - "data": { - "elts": [ - { - "node": { - "type": "Config", - "data": { - "items": [ + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "name", - "filename": "config_expr-03.k", - "line": 11, - "column": 13, - "end_line": 11, - "end_column": 17 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-03.k", - "line": 11, - "column": 13, - "end_line": 11, - "end_column": 17 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"ENV_2\"", - "value": "ENV_2" - } - }, - "filename": "config_expr-03.k", - "line": 11, - "column": 19, - "end_line": 11, - "end_column": 26 - }, - "operation": "Union", - "insert_index": -1 - }, + "node": "name", "filename": "config_expr-03.k", "line": 11, "column": 13, "end_line": 11, - "end_column": 26 - }, + "end_column": 17 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 11, + "column": 13, + "end_line": 11, + "end_column": 17 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"ENV_2\"", + "value": "ENV_2" + }, + "filename": "config_expr-03.k", + "line": 11, + "column": 19, + "end_line": 11, + "end_column": 26 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 11, + "column": 13, + "end_line": 11, + "end_column": 26 + }, + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "value", - "filename": "config_expr-03.k", - "line": 11, - "column": 28, - "end_line": 11, - "end_column": 33 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-03.k", - "line": 11, - "column": 28, - "end_line": 11, - "end_column": 33 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"2\"", - "value": "2" - } - }, - "filename": "config_expr-03.k", - "line": 11, - "column": 35, - "end_line": 11, - "end_column": 38 - }, - "operation": "Union", - "insert_index": -1 - }, + "node": "value", "filename": "config_expr-03.k", "line": 11, "column": 28, "end_line": 11, - "end_column": 38 + "end_column": 33 } - ] - } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 11, + "column": 28, + "end_line": 11, + "end_column": 33 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"2\"", + "value": "2" + }, + "filename": "config_expr-03.k", + "line": 11, + "column": 35, + "end_line": 11, + "end_column": 38 }, - "filename": "config_expr-03.k", - "line": 11, - "column": 12, - "end_line": 11, - "end_column": 39 - } - ], - "ctx": "Load" - } + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 11, + "column": 28, + "end_line": 11, + "end_column": 38 + } + ] }, "filename": "config_expr-03.k", - "line": 10, - "column": 15, - "end_line": 12, - "end_column": 9 - }, - "operation": "Insert", - "insert_index": -1 - }, - "filename": "config_expr-03.k", - "line": 10, - "column": 8, - "end_line": 12, - "end_column": 9 - } - ] - } - }, - "filename": "config_expr-03.k", - "line": 9, - "column": 10, - "end_line": 13, - "end_column": 5 - }, - "operation": "Union", - "insert_index": -1 + "line": 11, + "column": 12, + "end_line": 11, + "end_column": 39 + } + ], + "ctx": "Load" + }, + "filename": "config_expr-03.k", + "line": 10, + "column": 15, + "end_line": 12, + "end_column": 9 + }, + "operation": "Insert", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 10, + "column": 8, + "end_line": 12, + "end_column": 9 + } + ] }, "filename": "config_expr-03.k", "line": 9, - "column": 4, + "column": 10, "end_line": 13, "end_column": 5 - } - ] + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-03.k", + "line": 9, + "column": 4, + "end_line": 13, + "end_column": 5 } - }, - "filename": "config_expr-03.k", - "line": 3, - "column": 9, - "end_line": 14, - "end_column": 1 + ] }, - "ty": null - } + "filename": "config_expr-03.k", + "line": 3, + "column": 9, + "end_line": 14, + "end_column": 1 + }, + "ty": null }, "filename": "config_expr-03.k", "line": 3, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap index 0b1ea1383..1f4a8ab74 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__config_expr_4.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 13 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" --- { @@ -12,100 +11,94 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" { "node": { "type": "Schema", - "data": { - "doc": null, - "name": { - "node": "Env", + "doc": null, + "name": { + "node": "Env", + "filename": "config_expr-04.k", + "line": 3, + "column": 7, + "end_line": 3, + "end_column": 10 + }, + "parent_name": null, + "for_host_name": null, + "is_mixin": false, + "is_protocol": false, + "args": null, + "mixins": [], + "body": [ + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "name", + "filename": "config_expr-04.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 8 + }, + "op": null, + "value": null, + "is_optional": false, + "decorators": [], + "ty": { + "node": { + "type": "Basic", + "value": "Str" + }, + "filename": "config_expr-04.k", + "line": 4, + "column": 10, + "end_line": 4, + "end_column": 13 + } + }, "filename": "config_expr-04.k", - "line": 3, - "column": 7, - "end_line": 3, - "end_column": 10 + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 13 }, - "parent_name": null, - "for_host_name": null, - "is_mixin": false, - "is_protocol": false, - "args": null, - "mixins": [], - "body": [ - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "name", - "filename": "config_expr-04.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 8 - }, - "op": null, - "value": null, - "is_optional": false, - "decorators": [], - "ty": { - "node": { - "type": "Basic", - "data": "Str" - }, - "filename": "config_expr-04.k", - "line": 4, - "column": 10, - "end_line": 4, - "end_column": 13 - } - } + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "value", + "filename": "config_expr-04.k", + "line": 5, + "column": 4, + "end_line": 5, + "end_column": 9 }, - "filename": "config_expr-04.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 13 + "op": null, + "value": null, + "is_optional": false, + "decorators": [], + "ty": { + "node": { + "type": "Basic", + "value": "Str" + }, + "filename": "config_expr-04.k", + "line": 5, + "column": 11, + "end_line": 5, + "end_column": 14 + } }, - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "value", - "filename": "config_expr-04.k", - "line": 5, - "column": 4, - "end_line": 5, - "end_column": 9 - }, - "op": null, - "value": null, - "is_optional": false, - "decorators": [], - "ty": { - "node": { - "type": "Basic", - "data": "Str" - }, - "filename": "config_expr-04.k", - "line": 5, - "column": 11, - "end_line": 5, - "end_column": 14 - } - } - }, - "filename": "config_expr-04.k", - "line": 5, - "column": 4, - "end_line": 5, - "end_column": 14 - } - ], - "decorators": [], - "checks": [], - "index_signature": null - } + "filename": "config_expr-04.k", + "line": 5, + "column": 4, + "end_line": 5, + "end_column": 14 + } + ], + "decorators": [], + "checks": [], + "index_signature": null }, "filename": "config_expr-04.k", "line": 3, @@ -116,89 +109,85 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" { "node": { "type": "Schema", - "data": { - "doc": null, - "name": { - "node": "Main", - "filename": "config_expr-04.k", - "line": 7, - "column": 7, - "end_line": 7, - "end_column": 11 - }, - "parent_name": null, - "for_host_name": null, - "is_mixin": false, - "is_protocol": false, - "args": null, - "mixins": [], - "body": [ - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "env", - "filename": "config_expr-04.k", - "line": 8, - "column": 4, - "end_line": 8, - "end_column": 7 - }, - "op": null, - "value": null, - "is_optional": false, - "decorators": [], - "ty": { - "node": { - "type": "List", - "data": { - "inner_type": { - "node": { - "type": "Named", - "data": { - "names": [ - { - "node": "Env", - "filename": "config_expr-04.k", - "line": 8, - "column": 10, - "end_line": 8, - "end_column": 13 - } - ], - "pkgpath": "", - "ctx": "Load" + "doc": null, + "name": { + "node": "Main", + "filename": "config_expr-04.k", + "line": 7, + "column": 7, + "end_line": 7, + "end_column": 11 + }, + "parent_name": null, + "for_host_name": null, + "is_mixin": false, + "is_protocol": false, + "args": null, + "mixins": [], + "body": [ + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "env", + "filename": "config_expr-04.k", + "line": 8, + "column": 4, + "end_line": 8, + "end_column": 7 + }, + "op": null, + "value": null, + "is_optional": false, + "decorators": [], + "ty": { + "node": { + "type": "List", + "value": { + "inner_type": { + "node": { + "type": "Named", + "value": { + "names": [ + { + "node": "Env", + "filename": "config_expr-04.k", + "line": 8, + "column": 10, + "end_line": 8, + "end_column": 13 } - }, - "filename": "config_expr-04.k", - "line": 8, - "column": 10, - "end_line": 8, - "end_column": 13 + ], + "pkgpath": "", + "ctx": "Load" } - } - }, - "filename": "config_expr-04.k", - "line": 8, - "column": 9, - "end_line": 8, - "end_column": 14 + }, + "filename": "config_expr-04.k", + "line": 8, + "column": 10, + "end_line": 8, + "end_column": 13 + } } - } - }, - "filename": "config_expr-04.k", - "line": 8, - "column": 4, - "end_line": 8, - "end_column": 14 - } - ], - "decorators": [], - "checks": [], - "index_signature": null - } + }, + "filename": "config_expr-04.k", + "line": 8, + "column": 9, + "end_line": 8, + "end_column": 14 + } + }, + "filename": "config_expr-04.k", + "line": 8, + "column": 4, + "end_line": 8, + "end_column": 14 + } + ], + "decorators": [], + "checks": [], + "index_signature": null }, "filename": "config_expr-04.k", "line": 7, @@ -209,77 +198,73 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" { "node": { "type": "Schema", - "data": { - "doc": null, - "name": { - "node": "Config", - "filename": "config_expr-04.k", - "line": 10, - "column": 7, - "end_line": 10, - "end_column": 13 - }, - "parent_name": null, - "for_host_name": null, - "is_mixin": false, - "is_protocol": false, - "args": null, - "mixins": [], - "body": [ - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "main", - "filename": "config_expr-04.k", - "line": 11, - "column": 4, - "end_line": 11, - "end_column": 8 - }, - "op": null, - "value": null, - "is_optional": false, - "decorators": [], - "ty": { - "node": { - "type": "Named", - "data": { - "names": [ - { - "node": "Main", - "filename": "config_expr-04.k", - "line": 11, - "column": 10, - "end_line": 11, - "end_column": 14 - } - ], - "pkgpath": "", - "ctx": "Load" + "doc": null, + "name": { + "node": "Config", + "filename": "config_expr-04.k", + "line": 10, + "column": 7, + "end_line": 10, + "end_column": 13 + }, + "parent_name": null, + "for_host_name": null, + "is_mixin": false, + "is_protocol": false, + "args": null, + "mixins": [], + "body": [ + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "main", + "filename": "config_expr-04.k", + "line": 11, + "column": 4, + "end_line": 11, + "end_column": 8 + }, + "op": null, + "value": null, + "is_optional": false, + "decorators": [], + "ty": { + "node": { + "type": "Named", + "value": { + "names": [ + { + "node": "Main", + "filename": "config_expr-04.k", + "line": 11, + "column": 10, + "end_line": 11, + "end_column": 14 } - }, - "filename": "config_expr-04.k", - "line": 11, - "column": 10, - "end_line": 11, - "end_column": 14 + ], + "pkgpath": "", + "ctx": "Load" } - } - }, - "filename": "config_expr-04.k", - "line": 11, - "column": 4, - "end_line": 11, - "end_column": 14 - } - ], - "decorators": [], - "checks": [], - "index_signature": null - } + }, + "filename": "config_expr-04.k", + "line": 11, + "column": 10, + "end_line": 11, + "end_column": 14 + } + }, + "filename": "config_expr-04.k", + "line": 11, + "column": 4, + "end_line": 11, + "end_column": 14 + } + ], + "decorators": [], + "checks": [], + "index_signature": null }, "filename": "config_expr-04.k", "line": 10, @@ -290,245 +275,225 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { + "targets": [ + { + "node": { + "names": [ + { + "node": "_main", + "filename": "config_expr-04.k", + "line": 13, + "column": 0, + "end_line": 13, + "end_column": 5 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "config_expr-04.k", + "line": 13, + "column": 0, + "end_line": 13, + "end_column": 5 + } + ], + "value": { + "node": { + "type": "Schema", + "name": { "node": { "names": [ { - "node": "_main", + "node": "Main", "filename": "config_expr-04.k", "line": 13, - "column": 0, + "column": 8, "end_line": 13, - "end_column": 5 + "end_column": 12 } ], "pkgpath": "", - "ctx": "Store" + "ctx": "Load" }, "filename": "config_expr-04.k", "line": 13, - "column": 0, + "column": 8, "end_line": 13, - "end_column": 5 - } - ], - "value": { - "node": { - "type": "Schema", - "data": { - "name": { - "node": { - "names": [ - { - "node": "Main", - "filename": "config_expr-04.k", - "line": 13, - "column": 8, - "end_line": 13, - "end_column": 12 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "config_expr-04.k", - "line": 13, - "column": 8, - "end_line": 13, - "end_column": 12 - }, - "args": [], - "kwargs": [], - "config": { - "node": { - "type": "Config", - "data": { - "items": [ - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "env", - "filename": "config_expr-04.k", - "line": 14, - "column": 4, - "end_line": 14, - "end_column": 7 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "end_column": 12 + }, + "args": [], + "kwargs": [], + "config": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "env", "filename": "config_expr-04.k", "line": 14, "column": 4, "end_line": 14, "end_column": 7 - }, - "value": { + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 14, + "column": 4, + "end_line": 14, + "end_column": 7 + }, + "value": { + "node": { + "type": "List", + "elts": [ + { "node": { - "type": "List", - "data": { - "elts": [ - { - "node": { - "type": "Config", - "data": { - "items": [ + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "name", - "filename": "config_expr-04.k", - "line": 15, - "column": 9, - "end_line": 15, - "end_column": 13 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-04.k", - "line": 15, - "column": 9, - "end_line": 15, - "end_column": 13 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"ENV_1\"", - "value": "ENV_1" - } - }, - "filename": "config_expr-04.k", - "line": 15, - "column": 15, - "end_line": 15, - "end_column": 22 - }, - "operation": "Union", - "insert_index": -1 - }, + "node": "name", "filename": "config_expr-04.k", "line": 15, "column": 9, "end_line": 15, - "end_column": 22 - }, + "end_column": 13 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 15, + "column": 9, + "end_line": 15, + "end_column": 13 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"ENV_1\"", + "value": "ENV_1" + }, + "filename": "config_expr-04.k", + "line": 15, + "column": 15, + "end_line": 15, + "end_column": 22 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 15, + "column": 9, + "end_line": 15, + "end_column": 22 + }, + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "value", - "filename": "config_expr-04.k", - "line": 15, - "column": 24, - "end_line": 15, - "end_column": 29 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-04.k", - "line": 15, - "column": 24, - "end_line": 15, - "end_column": 29 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"1\"", - "value": "1" - } - }, - "filename": "config_expr-04.k", - "line": 15, - "column": 31, - "end_line": 15, - "end_column": 34 - }, - "operation": "Union", - "insert_index": -1 - }, + "node": "value", "filename": "config_expr-04.k", "line": 15, "column": 24, "end_line": 15, - "end_column": 34 + "end_column": 29 } - ] - } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 15, + "column": 24, + "end_line": 15, + "end_column": 29 }, - "filename": "config_expr-04.k", - "line": 15, - "column": 8, - "end_line": 15, - "end_column": 35 - } - ], - "ctx": "Load" - } + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"1\"", + "value": "1" + }, + "filename": "config_expr-04.k", + "line": 15, + "column": 31, + "end_line": 15, + "end_column": 34 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 15, + "column": 24, + "end_line": 15, + "end_column": 34 + } + ] }, "filename": "config_expr-04.k", - "line": 14, - "column": 9, - "end_line": 16, - "end_column": 5 - }, - "operation": "Union", - "insert_index": -1 - }, - "filename": "config_expr-04.k", - "line": 14, - "column": 4, - "end_line": 16, - "end_column": 5 - } - ] - } - }, - "filename": "config_expr-04.k", - "line": 13, - "column": 13, - "end_line": 17, - "end_column": 1 - } - } - }, - "filename": "config_expr-04.k", - "line": 13, - "column": 8, - "end_line": 17, - "end_column": 1 + "line": 15, + "column": 8, + "end_line": 15, + "end_column": 35 + } + ], + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 14, + "column": 9, + "end_line": 16, + "end_column": 5 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 14, + "column": 4, + "end_line": 16, + "end_column": 5 + } + ] + }, + "filename": "config_expr-04.k", + "line": 13, + "column": 13, + "end_line": 17, + "end_column": 1 + } }, - "ty": null - } + "filename": "config_expr-04.k", + "line": 13, + "column": 8, + "end_line": 17, + "end_column": 1 + }, + "ty": null }, "filename": "config_expr-04.k", "line": 13, @@ -539,388 +504,358 @@ expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { + "targets": [ + { + "node": { + "names": [ + { + "node": "config", + "filename": "config_expr-04.k", + "line": 19, + "column": 0, + "end_line": 19, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "config_expr-04.k", + "line": 19, + "column": 0, + "end_line": 19, + "end_column": 6 + } + ], + "value": { + "node": { + "type": "Schema", + "name": { "node": { "names": [ { - "node": "config", + "node": "Config", "filename": "config_expr-04.k", "line": 19, - "column": 0, + "column": 9, "end_line": 19, - "end_column": 6 + "end_column": 15 } ], "pkgpath": "", - "ctx": "Store" + "ctx": "Load" }, "filename": "config_expr-04.k", "line": 19, - "column": 0, + "column": 9, "end_line": 19, - "end_column": 6 - } - ], - "value": { - "node": { - "type": "Schema", - "data": { - "name": { - "node": { - "names": [ - { - "node": "Config", - "filename": "config_expr-04.k", - "line": 19, - "column": 9, - "end_line": 19, - "end_column": 15 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "config_expr-04.k", - "line": 19, - "column": 9, - "end_line": 19, - "end_column": 15 - }, - "args": [], - "kwargs": [], - "config": { - "node": { - "type": "Config", - "data": { - "items": [ - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "main", - "filename": "config_expr-04.k", - "line": 20, - "column": 4, - "end_line": 20, - "end_column": 8 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "end_column": 15 + }, + "args": [], + "kwargs": [], + "config": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "main", "filename": "config_expr-04.k", "line": 20, "column": 4, "end_line": 20, "end_column": 8 - }, - "value": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "_main", - "filename": "config_expr-04.k", - "line": 20, - "column": 10, - "end_line": 20, - "end_column": 15 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 20, + "column": 4, + "end_line": 20, + "end_column": 8 + }, + "value": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "_main", "filename": "config_expr-04.k", "line": 20, "column": 10, "end_line": 20, "end_column": 15 - }, - "operation": "Union", - "insert_index": -1 - }, - "filename": "config_expr-04.k", - "line": 20, - "column": 4, - "end_line": 20, - "end_column": 15 + } + ], + "pkgpath": "", + "ctx": "Load" }, - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "main", - "filename": "config_expr-04.k", - "line": 21, - "column": 4, - "end_line": 21, - "end_column": 8 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, + "filename": "config_expr-04.k", + "line": 20, + "column": 10, + "end_line": 20, + "end_column": 15 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 20, + "column": 4, + "end_line": 20, + "end_column": 15 + }, + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "main", "filename": "config_expr-04.k", "line": 21, "column": 4, "end_line": 21, "end_column": 8 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 21, + "column": 4, + "end_line": 21, + "end_column": 8 + }, + "value": { + "node": { + "type": "Schema", + "name": { + "node": { + "names": [ + { + "node": "Main", + "filename": "config_expr-04.k", + "line": 21, + "column": 10, + "end_line": 21, + "end_column": 14 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "value": { - "node": { - "type": "Schema", - "data": { - "name": { - "node": { - "names": [ - { - "node": "Main", - "filename": "config_expr-04.k", - "line": 21, - "column": 10, - "end_line": 21, - "end_column": 14 - } - ], - "pkgpath": "", - "ctx": "Load" + "filename": "config_expr-04.k", + "line": 21, + "column": 10, + "end_line": 21, + "end_column": 14 + }, + "args": [], + "kwargs": [], + "config": { + "node": { + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "env", + "filename": "config_expr-04.k", + "line": 22, + "column": 8, + "end_line": 22, + "end_column": 11 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 22, + "column": 8, + "end_line": 22, + "end_column": 11 }, - "filename": "config_expr-04.k", - "line": 21, - "column": 10, - "end_line": 21, - "end_column": 14 - }, - "args": [], - "kwargs": [], - "config": { - "node": { - "type": "Config", - "data": { - "items": [ + "value": { + "node": { + "type": "List", + "elts": [ { "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "env", - "filename": "config_expr-04.k", - "line": 22, - "column": 8, - "end_line": 22, - "end_column": 11 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-04.k", - "line": 22, - "column": 8, - "end_line": 22, - "end_column": 11 - }, - "value": { - "node": { - "type": "List", - "data": { - "elts": [ - { - "node": { - "type": "Config", - "data": { - "items": [ - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "name", - "filename": "config_expr-04.k", - "line": 23, - "column": 13, - "end_line": 23, - "end_column": 17 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-04.k", - "line": 23, - "column": 13, - "end_line": 23, - "end_column": 17 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"ENV_2\"", - "value": "ENV_2" - } - }, - "filename": "config_expr-04.k", - "line": 23, - "column": 19, - "end_line": 23, - "end_column": 26 - }, - "operation": "Union", - "insert_index": -1 - }, - "filename": "config_expr-04.k", - "line": 23, - "column": 13, - "end_line": 23, - "end_column": 26 - }, - { - "node": { - "key": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "value", - "filename": "config_expr-04.k", - "line": 23, - "column": 28, - "end_line": 23, - "end_column": 33 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "config_expr-04.k", - "line": 23, - "column": 28, - "end_line": 23, - "end_column": 33 - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"2\"", - "value": "2" - } - }, - "filename": "config_expr-04.k", - "line": 23, - "column": 35, - "end_line": 23, - "end_column": 38 - }, - "operation": "Union", - "insert_index": -1 - }, - "filename": "config_expr-04.k", - "line": 23, - "column": 28, - "end_line": 23, - "end_column": 38 - } - ] + "type": "Config", + "items": [ + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "name", + "filename": "config_expr-04.k", + "line": 23, + "column": 13, + "end_line": 23, + "end_column": 17 } - }, - "filename": "config_expr-04.k", - "line": 23, - "column": 12, - "end_line": 23, - "end_column": 39 - } - ], - "ctx": "Load" - } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 23, + "column": 13, + "end_line": 23, + "end_column": 17 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"ENV_2\"", + "value": "ENV_2" + }, + "filename": "config_expr-04.k", + "line": 23, + "column": 19, + "end_line": 23, + "end_column": 26 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 23, + "column": 13, + "end_line": 23, + "end_column": 26 }, - "filename": "config_expr-04.k", - "line": 22, - "column": 15, - "end_line": 24, - "end_column": 9 - }, - "operation": "Insert", - "insert_index": -1 + { + "node": { + "key": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "value", + "filename": "config_expr-04.k", + "line": 23, + "column": 28, + "end_line": 23, + "end_column": 33 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 23, + "column": 28, + "end_line": 23, + "end_column": 33 + }, + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"2\"", + "value": "2" + }, + "filename": "config_expr-04.k", + "line": 23, + "column": 35, + "end_line": 23, + "end_column": 38 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 23, + "column": 28, + "end_line": 23, + "end_column": 38 + } + ] }, "filename": "config_expr-04.k", - "line": 22, - "column": 8, - "end_line": 24, - "end_column": 9 + "line": 23, + "column": 12, + "end_line": 23, + "end_column": 39 } - ] - } + ], + "ctx": "Load" + }, + "filename": "config_expr-04.k", + "line": 22, + "column": 15, + "end_line": 24, + "end_column": 9 }, - "filename": "config_expr-04.k", - "line": 21, - "column": 15, - "end_line": 25, - "end_column": 5 - } + "operation": "Insert", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 22, + "column": 8, + "end_line": 24, + "end_column": 9 } - }, - "filename": "config_expr-04.k", - "line": 21, - "column": 10, - "end_line": 25, - "end_column": 5 + ] }, - "operation": "Union", - "insert_index": -1 - }, - "filename": "config_expr-04.k", - "line": 21, - "column": 4, - "end_line": 25, - "end_column": 5 - } - ] - } - }, - "filename": "config_expr-04.k", - "line": 19, - "column": 16, - "end_line": 26, - "end_column": 1 - } - } - }, - "filename": "config_expr-04.k", - "line": 19, - "column": 9, - "end_line": 26, - "end_column": 1 + "filename": "config_expr-04.k", + "line": 21, + "column": 15, + "end_line": 25, + "end_column": 5 + } + }, + "filename": "config_expr-04.k", + "line": 21, + "column": 10, + "end_line": 25, + "end_column": 5 + }, + "operation": "Union", + "insert_index": -1 + }, + "filename": "config_expr-04.k", + "line": 21, + "column": 4, + "end_line": 25, + "end_column": 5 + } + ] + }, + "filename": "config_expr-04.k", + "line": 19, + "column": 16, + "end_line": 26, + "end_column": 1 + } }, - "ty": null - } + "filename": "config_expr-04.k", + "line": 19, + "column": 9, + "end_line": 26, + "end_column": 1 + }, + "ty": null }, "filename": "config_expr-04.k", "line": 19, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap index 2b2126843..760a592b0 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__hello_win.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 19 expression: "crate::tests::parsing_file_string(\"testdata/hello_win.k\")" --- { @@ -12,81 +11,72 @@ expression: "crate::tests::parsing_file_string(\"testdata/hello_win.k\")" { "node": { "type": "Schema", - "data": { - "doc": null, - "name": { - "node": "Person", - "filename": "hello_win.k", - "line": 2, - "column": 7, - "end_line": 2, - "end_column": 13 - }, - "parent_name": null, - "for_host_name": null, - "is_mixin": false, - "is_protocol": false, - "args": null, - "mixins": [], - "body": [ - { - "node": { - "type": "SchemaAttr", - "data": { - "doc": "", - "name": { - "node": "name", - "filename": "hello_win.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 8 - }, - "op": { - "type": "Aug", - "data": "Assign" - }, - "value": { - "node": { - "type": "StringLit", - "data": { - "is_long_string": false, - "raw_value": "\"kcl\"", - "value": "kcl" - } - }, - "filename": "hello_win.k", - "line": 3, - "column": 16, - "end_line": 3, - "end_column": 21 - }, - "is_optional": false, - "decorators": [], - "ty": { - "node": { - "type": "Basic", - "data": "Str" - }, - "filename": "hello_win.k", - "line": 3, - "column": 10, - "end_line": 3, - "end_column": 13 - } - } + "doc": null, + "name": { + "node": "Person", + "filename": "hello_win.k", + "line": 2, + "column": 7, + "end_line": 2, + "end_column": 13 + }, + "parent_name": null, + "for_host_name": null, + "is_mixin": false, + "is_protocol": false, + "args": null, + "mixins": [], + "body": [ + { + "node": { + "type": "SchemaAttr", + "doc": "", + "name": { + "node": "name", + "filename": "hello_win.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 8 }, - "filename": "hello_win.k", - "line": 3, - "column": 4, - "end_line": 3, - "end_column": 21 - } - ], - "decorators": [], - "checks": [], - "index_signature": null - } + "op": "Assign", + "value": { + "node": { + "type": "StringLit", + "is_long_string": false, + "raw_value": "\"kcl\"", + "value": "kcl" + }, + "filename": "hello_win.k", + "line": 3, + "column": 16, + "end_line": 3, + "end_column": 21 + }, + "is_optional": false, + "decorators": [], + "ty": { + "node": { + "type": "Basic", + "value": "Str" + }, + "filename": "hello_win.k", + "line": 3, + "column": 10, + "end_line": 3, + "end_column": 13 + } + }, + "filename": "hello_win.k", + "line": 3, + "column": 4, + "end_line": 3, + "end_column": 21 + } + ], + "decorators": [], + "checks": [], + "index_signature": null }, "filename": "hello_win.k", "line": 2, @@ -97,80 +87,74 @@ expression: "crate::tests::parsing_file_string(\"testdata/hello_win.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { + "targets": [ + { + "node": { + "names": [ + { + "node": "x0", + "filename": "hello_win.k", + "line": 5, + "column": 0, + "end_line": 5, + "end_column": 2 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "hello_win.k", + "line": 5, + "column": 0, + "end_line": 5, + "end_column": 2 + } + ], + "value": { + "node": { + "type": "Schema", + "name": { "node": { "names": [ { - "node": "x0", + "node": "Person", "filename": "hello_win.k", "line": 5, - "column": 0, + "column": 5, "end_line": 5, - "end_column": 2 + "end_column": 11 } ], "pkgpath": "", - "ctx": "Store" + "ctx": "Load" }, "filename": "hello_win.k", "line": 5, - "column": 0, + "column": 5, "end_line": 5, - "end_column": 2 - } - ], - "value": { - "node": { - "type": "Schema", - "data": { - "name": { - "node": { - "names": [ - { - "node": "Person", - "filename": "hello_win.k", - "line": 5, - "column": 5, - "end_line": 5, - "end_column": 11 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "hello_win.k", - "line": 5, - "column": 5, - "end_line": 5, - "end_column": 11 - }, - "args": [], - "kwargs": [], - "config": { - "node": { - "type": "Config", - "data": { - "items": [] - } - }, - "filename": "hello_win.k", - "line": 5, - "column": 12, - "end_line": 5, - "end_column": 14 - } - } + "end_column": 11 }, - "filename": "hello_win.k", - "line": 5, - "column": 5, - "end_line": 5, - "end_column": 14 + "args": [], + "kwargs": [], + "config": { + "node": { + "type": "Config", + "items": [] + }, + "filename": "hello_win.k", + "line": 5, + "column": 12, + "end_line": 5, + "end_column": 14 + } }, - "ty": null - } + "filename": "hello_win.k", + "line": 5, + "column": 5, + "end_line": 5, + "end_column": 14 + }, + "ty": null }, "filename": "hello_win.k", "line": 5, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_1.snap index 25f90232a..b5c56d05a 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 15 expression: "crate::tests::parsing_file_string(\"testdata/if-01.k\")" --- { @@ -12,49 +11,45 @@ expression: "crate::tests::parsing_file_string(\"testdata/if-01.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "a", - "filename": "if-01.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-01.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 + "names": [ + { + "node": "a", + "filename": "if-01.k", + "line": 1, + "column": 0, + "end_line": 1, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "if-01.k", "line": 1, - "column": 4, + "column": 0, "end_line": 1, - "end_column": 5 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } }, - "ty": null - } + "filename": "if-01.k", + "line": 1, + "column": 4, + "end_line": 1, + "end_column": 5 + }, + "ty": null }, "filename": "if-01.k", "line": 1, @@ -65,88 +60,80 @@ expression: "crate::tests::parsing_file_string(\"testdata/if-01.k\")" { "node": { "type": "If", - "data": { - "body": [ - { - "node": { - "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "bbb", - "filename": "if-01.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 7 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-01.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 7 - } - ], - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 2 - } + "body": [ + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ + { + "node": "bbb", + "filename": "if-01.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 7 } - }, - "filename": "if-01.k", - "line": 4, - "column": 10, - "end_line": 4, - "end_column": 11 + ], + "pkgpath": "", + "ctx": "Store" }, - "ty": null + "filename": "if-01.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 7 } - }, - "filename": "if-01.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 11 - } - ], - "cond": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "if-01.k", - "line": 3, - "column": 3, - "end_line": 3, - "end_column": 4 + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 2 } - ], - "pkgpath": "", - "ctx": "Load" - } + }, + "filename": "if-01.k", + "line": 4, + "column": 10, + "end_line": 4, + "end_column": 11 + }, + "ty": null }, "filename": "if-01.k", - "line": 3, - "column": 3, - "end_line": 3, - "end_column": 4 + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 11 + } + ], + "cond": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "a", + "filename": "if-01.k", + "line": 3, + "column": 3, + "end_line": 3, + "end_column": 4 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "orelse": [] - } + "filename": "if-01.k", + "line": 3, + "column": 3, + "end_line": 3, + "end_column": 4 + }, + "orelse": [] }, "filename": "if-01.k", "line": 3, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_2.snap index 3d56a202a..eb9612718 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_2.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 16 expression: "crate::tests::parsing_file_string(\"testdata/if-02.k\")" --- { @@ -12,49 +11,45 @@ expression: "crate::tests::parsing_file_string(\"testdata/if-02.k\")" { "node": { "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "a", - "filename": "if-02.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-02.k", - "line": 1, - "column": 0, - "end_line": 1, - "end_column": 1 - } - ], - "value": { + "targets": [ + { "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 + "names": [ + { + "node": "a", + "filename": "if-02.k", + "line": 1, + "column": 0, + "end_line": 1, + "end_column": 1 } - } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "if-02.k", "line": 1, - "column": 4, + "column": 0, "end_line": 1, - "end_column": 5 + "end_column": 1 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } }, - "ty": null - } + "filename": "if-02.k", + "line": 1, + "column": 4, + "end_line": 1, + "end_column": 5 + }, + "ty": null }, "filename": "if-02.k", "line": 1, @@ -65,106 +60,200 @@ expression: "crate::tests::parsing_file_string(\"testdata/if-02.k\")" { "node": { "type": "If", - "data": { - "body": [ - { - "node": { - "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "bbb", - "filename": "if-02.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 7 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-02.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 7 - } - ], + "body": [ + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ + { + "node": "bbb", + "filename": "if-02.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 7 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "if-02.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 7 + } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, "value": { - "node": { - "type": "NumberLit", - "data": { + "type": "Int", + "value": 2 + } + }, + "filename": "if-02.k", + "line": 4, + "column": 10, + "end_line": 4, + "end_column": 11 + }, + "ty": null + }, + "filename": "if-02.k", + "line": 4, + "column": 4, + "end_line": 4, + "end_column": 11 + } + ], + "cond": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "a", + "filename": "if-02.k", + "line": 3, + "column": 3, + "end_line": 3, + "end_column": 4 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "if-02.k", + "line": 3, + "column": 3, + "end_line": 3, + "end_column": 4 + }, + "orelse": [ + { + "node": { + "type": "If", + "body": [ + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ + { + "node": "ccc", + "filename": "if-02.k", + "line": 6, + "column": 4, + "end_line": 6, + "end_column": 7 + } + ], + "pkgpath": "", + "ctx": "Store" + }, + "filename": "if-02.k", + "line": 6, + "column": 4, + "end_line": 6, + "end_column": 7 + } + ], + "value": { + "node": { + "type": "NumberLit", "binary_suffix": null, "value": { "type": "Int", - "data": 2 + "value": 3 } - } + }, + "filename": "if-02.k", + "line": 6, + "column": 10, + "end_line": 6, + "end_column": 11 }, - "filename": "if-02.k", - "line": 4, - "column": 10, - "end_line": 4, - "end_column": 11 + "ty": null }, - "ty": null + "filename": "if-02.k", + "line": 6, + "column": 4, + "end_line": 6, + "end_column": 11 } - }, - "filename": "if-02.k", - "line": 4, - "column": 4, - "end_line": 4, - "end_column": 11 - } - ], - "cond": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", + ], + "cond": { + "node": { + "type": "Binary", + "left": { + "node": { + "type": "Identifier", + "names": [ + { + "node": "a", + "filename": "if-02.k", + "line": 5, + "column": 5, + "end_line": 5, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "if-02.k", + "line": 5, + "column": 5, + "end_line": 5, + "end_column": 6 + }, + "op": "Add", + "right": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 10 + } + }, "filename": "if-02.k", - "line": 3, - "column": 3, - "end_line": 3, - "end_column": 4 + "line": 5, + "column": 9, + "end_line": 5, + "end_column": 11 } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "if-02.k", - "line": 3, - "column": 3, - "end_line": 3, - "end_column": 4 - }, - "orelse": [ - { - "node": { - "type": "If", - "data": { - "body": [ - { - "node": { - "type": "Assign", - "data": { + }, + "filename": "if-02.k", + "line": 5, + "column": 5, + "end_line": 5, + "end_column": 11 + }, + "orelse": [ + { + "node": { + "type": "If", + "body": [ + { + "node": { + "type": "Assign", "targets": [ { "node": { "names": [ { - "node": "ccc", + "node": "ddd", "filename": "if-02.k", - "line": 6, + "line": 8, "column": 4, - "end_line": 6, + "end_line": 8, "end_column": 7 } ], @@ -172,340 +261,200 @@ expression: "crate::tests::parsing_file_string(\"testdata/if-02.k\")" "ctx": "Store" }, "filename": "if-02.k", - "line": 6, + "line": 8, "column": 4, - "end_line": 6, + "end_line": 8, "end_column": 7 } ], "value": { "node": { "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 3 - } + "binary_suffix": null, + "value": { + "type": "Int", + "value": 4 } }, "filename": "if-02.k", - "line": 6, + "line": 8, "column": 10, - "end_line": 6, + "end_line": 8, "end_column": 11 }, "ty": null - } - }, - "filename": "if-02.k", - "line": 6, - "column": 4, - "end_line": 6, - "end_column": 11 - } - ], - "cond": { - "node": { - "type": "Binary", - "data": { + }, + "filename": "if-02.k", + "line": 8, + "column": 4, + "end_line": 8, + "end_column": 11 + } + ], + "cond": { + "node": { + "type": "Binary", "left": { "node": { "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "if-02.k", - "line": 5, - "column": 5, - "end_line": 5, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } + "names": [ + { + "node": "a", + "filename": "if-02.k", + "line": 7, + "column": 5, + "end_line": 7, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" }, "filename": "if-02.k", - "line": 5, + "line": 7, "column": 5, - "end_line": 5, + "end_line": 7, "end_column": 6 }, - "op": { - "type": "Bin", - "data": "Add" - }, + "op": "Add", "right": { "node": { "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 10 - } + "binary_suffix": null, + "value": { + "type": "Int", + "value": 100 } }, "filename": "if-02.k", - "line": 5, + "line": 7, "column": 9, - "end_line": 5, - "end_column": 11 + "end_line": 7, + "end_column": 12 } - } + }, + "filename": "if-02.k", + "line": 7, + "column": 5, + "end_line": 7, + "end_column": 12 }, - "filename": "if-02.k", - "line": 5, - "column": 5, - "end_line": 5, - "end_column": 11 - }, - "orelse": [ - { - "node": { - "type": "If", - "data": { - "body": [ + "orelse": [ + { + "node": { + "type": "Assign", + "targets": [ { "node": { - "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "ddd", - "filename": "if-02.k", - "line": 8, - "column": 4, - "end_line": 8, - "end_column": 7 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-02.k", - "line": 8, - "column": 4, - "end_line": 8, - "end_column": 7 - } - ], - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 4 - } - } - }, + "names": [ + { + "node": "eee", "filename": "if-02.k", - "line": 8, - "column": 10, - "end_line": 8, - "end_column": 11 - }, - "ty": null - } + "line": 10, + "column": 4, + "end_line": 10, + "end_column": 7 + } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "if-02.k", - "line": 8, + "line": 10, "column": 4, - "end_line": 8, - "end_column": 11 + "end_line": 10, + "end_column": 7 } ], - "cond": { + "value": { "node": { - "type": "Binary", - "data": { - "left": { - "node": { - "type": "Identifier", - "data": { - "names": [ - { - "node": "a", - "filename": "if-02.k", - "line": 7, - "column": 5, - "end_line": 7, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - } - }, - "filename": "if-02.k", - "line": 7, - "column": 5, - "end_line": 7, - "end_column": 6 - }, - "op": { - "type": "Bin", - "data": "Add" - }, - "right": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 100 - } - } - }, - "filename": "if-02.k", - "line": 7, - "column": 9, - "end_line": 7, - "end_column": 12 - } + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 5 } }, "filename": "if-02.k", - "line": 7, - "column": 5, - "end_line": 7, - "end_column": 12 + "line": 10, + "column": 10, + "end_line": 10, + "end_column": 11 }, - "orelse": [ - { - "node": { - "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "eee", - "filename": "if-02.k", - "line": 10, - "column": 4, - "end_line": 10, - "end_column": 7 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-02.k", - "line": 10, - "column": 4, - "end_line": 10, - "end_column": 7 - } - ], - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 5 - } - } - }, - "filename": "if-02.k", - "line": 10, - "column": 10, - "end_line": 10, - "end_column": 11 - }, - "ty": null - } - }, - "filename": "if-02.k", - "line": 10, - "column": 4, - "end_line": 10, - "end_column": 11 - }, + "ty": null + }, + "filename": "if-02.k", + "line": 10, + "column": 4, + "end_line": 10, + "end_column": 11 + }, + { + "node": { + "type": "Assign", + "targets": [ { "node": { - "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "fff", - "filename": "if-02.k", - "line": 11, - "column": 4, - "end_line": 11, - "end_column": 7 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-02.k", - "line": 11, - "column": 4, - "end_line": 11, - "end_column": 7 - } - ], - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 6 - } - } - }, + "names": [ + { + "node": "fff", "filename": "if-02.k", "line": 11, - "column": 10, + "column": 4, "end_line": 11, - "end_column": 11 - }, - "ty": null - } + "end_column": 7 + } + ], + "pkgpath": "", + "ctx": "Store" }, "filename": "if-02.k", "line": 11, "column": 4, "end_line": 11, - "end_column": 11 + "end_column": 7 } - ] - } - }, - "filename": "if-02.k", - "line": 7, - "column": 0, - "end_line": 11, - "end_column": 11 - } - ] + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 6 + } + }, + "filename": "if-02.k", + "line": 11, + "column": 10, + "end_line": 11, + "end_column": 11 + }, + "ty": null + }, + "filename": "if-02.k", + "line": 11, + "column": 4, + "end_line": 11, + "end_column": 11 + } + ] + }, + "filename": "if-02.k", + "line": 7, + "column": 0, + "end_line": 11, + "end_column": 11 } - }, - "filename": "if-02.k", - "line": 5, - "column": 0, - "end_line": 11, - "end_column": 11 - } - ] - } + ] + }, + "filename": "if-02.k", + "line": 5, + "column": 0, + "end_line": 11, + "end_column": 11 + } + ] }, "filename": "if-02.k", "line": 3, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_3.snap index fee335be0..d1db8d1b4 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__if_3.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 17 expression: "crate::tests::parsing_file_string(\"testdata/if-03.k\")" --- { @@ -12,77 +11,69 @@ expression: "crate::tests::parsing_file_string(\"testdata/if-03.k\")" { "node": { "type": "If", - "data": { - "body": [ - { - "node": { - "type": "Assign", - "data": { - "targets": [ - { - "node": { - "names": [ - { - "node": "a", - "filename": "if-03.k", - "line": 1, - "column": 9, - "end_line": 1, - "end_column": 10 - } - ], - "pkgpath": "", - "ctx": "Store" - }, - "filename": "if-03.k", - "line": 1, - "column": 9, - "end_line": 1, - "end_column": 10 - } - ], - "value": { - "node": { - "type": "NumberLit", - "data": { - "binary_suffix": null, - "value": { - "type": "Int", - "data": 1 - } + "body": [ + { + "node": { + "type": "Assign", + "targets": [ + { + "node": { + "names": [ + { + "node": "a", + "filename": "if-03.k", + "line": 1, + "column": 9, + "end_line": 1, + "end_column": 10 } - }, - "filename": "if-03.k", - "line": 1, - "column": 13, - "end_line": 1, - "end_column": 14 + ], + "pkgpath": "", + "ctx": "Store" }, - "ty": null + "filename": "if-03.k", + "line": 1, + "column": 9, + "end_line": 1, + "end_column": 10 } + ], + "value": { + "node": { + "type": "NumberLit", + "binary_suffix": null, + "value": { + "type": "Int", + "value": 1 + } + }, + "filename": "if-03.k", + "line": 1, + "column": 13, + "end_line": 1, + "end_column": 14 }, - "filename": "if-03.k", - "line": 1, - "column": 9, - "end_line": 1, - "end_column": 14 - } - ], - "cond": { - "node": { - "type": "NameConstantLit", - "data": { - "value": "True" - } + "ty": null }, "filename": "if-03.k", "line": 1, - "column": 3, + "column": 9, "end_line": 1, - "end_column": 7 + "end_column": 14 + } + ], + "cond": { + "node": { + "type": "NameConstantLit", + "value": "True" }, - "orelse": [] - } + "filename": "if-03.k", + "line": 1, + "column": 3, + "end_line": 1, + "end_column": 7 + }, + "orelse": [] }, "filename": "if-03.k", "line": 1, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__import_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__import_1.snap index 1eee5ccce..887c422e5 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__import_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__import_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 14 expression: "crate::tests::parsing_file_string(\"testdata/import-01.k\")" --- { @@ -12,20 +11,18 @@ expression: "crate::tests::parsing_file_string(\"testdata/import-01.k\")" { "node": { "type": "Import", - "data": { - "path": { - "node": "a1", - "filename": "import-01.k", - "line": 1, - "column": 7, - "end_line": 1, - "end_column": 9 - }, - "rawpath": "a1", - "name": "a1", - "asname": null, - "pkg_name": "__main__" - } + "path": { + "node": "a1", + "filename": "import-01.k", + "line": 1, + "column": 7, + "end_line": 1, + "end_column": 9 + }, + "rawpath": "a1", + "name": "a1", + "asname": null, + "pkg_name": "__main__" }, "filename": "import-01.k", "line": 1, @@ -36,27 +33,25 @@ expression: "crate::tests::parsing_file_string(\"testdata/import-01.k\")" { "node": { "type": "Import", - "data": { - "path": { - "node": "a2", - "filename": "import-01.k", - "line": 3, - "column": 7, - "end_line": 3, - "end_column": 9 - }, - "rawpath": "a2", - "name": "a2_pkg", - "asname": { - "node": "a2_pkg", - "filename": "import-01.k", - "line": 3, - "column": 13, - "end_line": 3, - "end_column": 19 - }, - "pkg_name": "__main__" - } + "path": { + "node": "a2", + "filename": "import-01.k", + "line": 3, + "column": 7, + "end_line": 3, + "end_column": 9 + }, + "rawpath": "a2", + "name": "a2_pkg", + "asname": { + "node": "a2_pkg", + "filename": "import-01.k", + "line": 3, + "column": 13, + "end_line": 3, + "end_column": 19 + }, + "pkg_name": "__main__" }, "filename": "import-01.k", "line": 3, @@ -67,20 +62,18 @@ expression: "crate::tests::parsing_file_string(\"testdata/import-01.k\")" { "node": { "type": "Import", - "data": { - "path": { - "node": "subpkg.b1.c1", - "filename": "import-01.k", - "line": 5, - "column": 7, - "end_line": 5, - "end_column": 19 - }, - "rawpath": "subpkg.b1.c1", - "name": "c1", - "asname": null, - "pkg_name": "__main__" - } + "path": { + "node": "subpkg.b1.c1", + "filename": "import-01.k", + "line": 5, + "column": 7, + "end_line": 5, + "end_column": 19 + }, + "rawpath": "subpkg.b1.c1", + "name": "c1", + "asname": null, + "pkg_name": "__main__" }, "filename": "import-01.k", "line": 5, @@ -91,20 +84,18 @@ expression: "crate::tests::parsing_file_string(\"testdata/import-01.k\")" { "node": { "type": "Import", - "data": { - "path": { - "node": "a3", - "filename": "import-01.k", - "line": 7, - "column": 7, - "end_line": 7, - "end_column": 10 - }, - "rawpath": ".a3", - "name": "a3", - "asname": null, - "pkg_name": "__main__" - } + "path": { + "node": "a3", + "filename": "import-01.k", + "line": 7, + "column": 7, + "end_line": 7, + "end_column": 10 + }, + "rawpath": ".a3", + "name": "a3", + "asname": null, + "pkg_name": "__main__" }, "filename": "import-01.k", "line": 7, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap index c7b898af3..91ac6fa3a 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__file__type_1.snap @@ -1,6 +1,5 @@ --- source: parser/src/tests/file.rs -assertion_line: 18 expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" --- { @@ -12,46 +11,44 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "a", - "filename": "type-01.k", - "line": 1, - "column": 5, - "end_line": 1, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 1, - "column": 5, - "end_line": 1, - "end_column": 6 + "type_name": { + "node": { + "names": [ + { + "node": "a", + "filename": "type-01.k", + "line": 1, + "column": 5, + "end_line": 1, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "type_value": { - "node": "any", - "filename": "type-01.k", - "line": 1, - "column": 9, - "end_line": 1, - "end_column": 12 + "filename": "type-01.k", + "line": 1, + "column": 5, + "end_line": 1, + "end_column": 6 + }, + "type_value": { + "node": "any", + "filename": "type-01.k", + "line": 1, + "column": 9, + "end_line": 1, + "end_column": 12 + }, + "ty": { + "node": { + "type": "Any" }, - "ty": { - "node": { - "type": "Any" - }, - "filename": "type-01.k", - "line": 1, - "column": 9, - "end_line": 1, - "end_column": 12 - } + "filename": "type-01.k", + "line": 1, + "column": 9, + "end_line": 1, + "end_column": 12 } }, "filename": "type-01.k", @@ -63,47 +60,45 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "b", - "filename": "type-01.k", - "line": 3, - "column": 5, - "end_line": 3, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 3, - "column": 5, - "end_line": 3, - "end_column": 6 + "type_name": { + "node": { + "names": [ + { + "node": "b", + "filename": "type-01.k", + "line": 3, + "column": 5, + "end_line": 3, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "type_value": { - "node": "bool", - "filename": "type-01.k", - "line": 3, - "column": 9, - "end_line": 3, - "end_column": 13 + "filename": "type-01.k", + "line": 3, + "column": 5, + "end_line": 3, + "end_column": 6 + }, + "type_value": { + "node": "bool", + "filename": "type-01.k", + "line": 3, + "column": 9, + "end_line": 3, + "end_column": 13 + }, + "ty": { + "node": { + "type": "Basic", + "value": "Bool" }, - "ty": { - "node": { - "type": "Basic", - "data": "Bool" - }, - "filename": "type-01.k", - "line": 3, - "column": 9, - "end_line": 3, - "end_column": 13 - } + "filename": "type-01.k", + "line": 3, + "column": 9, + "end_line": 3, + "end_column": 13 } }, "filename": "type-01.k", @@ -115,47 +110,45 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "c", - "filename": "type-01.k", - "line": 4, - "column": 5, - "end_line": 4, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 4, - "column": 5, - "end_line": 4, - "end_column": 6 + "type_name": { + "node": { + "names": [ + { + "node": "c", + "filename": "type-01.k", + "line": 4, + "column": 5, + "end_line": 4, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "type_value": { - "node": "int", - "filename": "type-01.k", - "line": 4, - "column": 9, - "end_line": 4, - "end_column": 12 + "filename": "type-01.k", + "line": 4, + "column": 5, + "end_line": 4, + "end_column": 6 + }, + "type_value": { + "node": "int", + "filename": "type-01.k", + "line": 4, + "column": 9, + "end_line": 4, + "end_column": 12 + }, + "ty": { + "node": { + "type": "Basic", + "value": "Int" }, - "ty": { - "node": { - "type": "Basic", - "data": "Int" - }, - "filename": "type-01.k", - "line": 4, - "column": 9, - "end_line": 4, - "end_column": 12 - } + "filename": "type-01.k", + "line": 4, + "column": 9, + "end_line": 4, + "end_column": 12 } }, "filename": "type-01.k", @@ -167,47 +160,45 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "d", - "filename": "type-01.k", - "line": 5, - "column": 5, - "end_line": 5, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 5, - "column": 5, - "end_line": 5, - "end_column": 6 + "type_name": { + "node": { + "names": [ + { + "node": "d", + "filename": "type-01.k", + "line": 5, + "column": 5, + "end_line": 5, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "type_value": { - "node": "float", - "filename": "type-01.k", - "line": 5, - "column": 9, - "end_line": 5, - "end_column": 14 + "filename": "type-01.k", + "line": 5, + "column": 5, + "end_line": 5, + "end_column": 6 + }, + "type_value": { + "node": "float", + "filename": "type-01.k", + "line": 5, + "column": 9, + "end_line": 5, + "end_column": 14 + }, + "ty": { + "node": { + "type": "Basic", + "value": "Float" }, - "ty": { - "node": { - "type": "Basic", - "data": "Float" - }, - "filename": "type-01.k", - "line": 5, - "column": 9, - "end_line": 5, - "end_column": 14 - } + "filename": "type-01.k", + "line": 5, + "column": 9, + "end_line": 5, + "end_column": 14 } }, "filename": "type-01.k", @@ -219,47 +210,45 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "e", - "filename": "type-01.k", - "line": 6, - "column": 5, - "end_line": 6, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 6, - "column": 5, - "end_line": 6, - "end_column": 6 + "type_name": { + "node": { + "names": [ + { + "node": "e", + "filename": "type-01.k", + "line": 6, + "column": 5, + "end_line": 6, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "type_value": { - "node": "str", - "filename": "type-01.k", - "line": 6, - "column": 9, - "end_line": 6, - "end_column": 12 + "filename": "type-01.k", + "line": 6, + "column": 5, + "end_line": 6, + "end_column": 6 + }, + "type_value": { + "node": "str", + "filename": "type-01.k", + "line": 6, + "column": 9, + "end_line": 6, + "end_column": 12 + }, + "ty": { + "node": { + "type": "Basic", + "value": "Str" }, - "ty": { - "node": { - "type": "Basic", - "data": "Str" - }, - "filename": "type-01.k", - "line": 6, - "column": 9, - "end_line": 6, - "end_column": 12 - } + "filename": "type-01.k", + "line": 6, + "column": 9, + "end_line": 6, + "end_column": 12 } }, "filename": "type-01.k", @@ -271,49 +260,47 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "type_list1", - "filename": "type-01.k", - "line": 8, - "column": 5, - "end_line": 8, - "end_column": 15 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 8, - "column": 5, - "end_line": 8, - "end_column": 15 + "type_name": { + "node": { + "names": [ + { + "node": "type_list1", + "filename": "type-01.k", + "line": 8, + "column": 5, + "end_line": 8, + "end_column": 15 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "type_value": { - "node": "[]", - "filename": "type-01.k", - "line": 8, - "column": 18, - "end_line": 8, - "end_column": 20 + "filename": "type-01.k", + "line": 8, + "column": 5, + "end_line": 8, + "end_column": 15 + }, + "type_value": { + "node": "[]", + "filename": "type-01.k", + "line": 8, + "column": 18, + "end_line": 8, + "end_column": 20 + }, + "ty": { + "node": { + "type": "List", + "value": { + "inner_type": null + } }, - "ty": { - "node": { - "type": "List", - "data": { - "inner_type": null - } - }, - "filename": "type-01.k", - "line": 8, - "column": 18, - "end_line": 8, - "end_column": 20 - } + "filename": "type-01.k", + "line": 8, + "column": 18, + "end_line": 8, + "end_column": 20 } }, "filename": "type-01.k", @@ -325,61 +312,59 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "type_list2", - "filename": "type-01.k", - "line": 9, - "column": 5, - "end_line": 9, - "end_column": 15 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 9, - "column": 5, - "end_line": 9, - "end_column": 15 - }, - "type_value": { - "node": "[[]]", - "filename": "type-01.k", - "line": 9, - "column": 18, - "end_line": 9, - "end_column": 22 + "type_name": { + "node": { + "names": [ + { + "node": "type_list2", + "filename": "type-01.k", + "line": 9, + "column": 5, + "end_line": 9, + "end_column": 15 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "ty": { - "node": { - "type": "List", - "data": { - "inner_type": { - "node": { - "type": "List", - "data": { - "inner_type": null - } - }, - "filename": "type-01.k", - "line": 9, - "column": 19, - "end_line": 9, - "end_column": 21 - } + "filename": "type-01.k", + "line": 9, + "column": 5, + "end_line": 9, + "end_column": 15 + }, + "type_value": { + "node": "[[]]", + "filename": "type-01.k", + "line": 9, + "column": 18, + "end_line": 9, + "end_column": 22 + }, + "ty": { + "node": { + "type": "List", + "value": { + "inner_type": { + "node": { + "type": "List", + "value": { + "inner_type": null + } + }, + "filename": "type-01.k", + "line": 9, + "column": 19, + "end_line": 9, + "end_column": 21 } - }, - "filename": "type-01.k", - "line": 9, - "column": 18, - "end_line": 9, - "end_column": 22 - } + } + }, + "filename": "type-01.k", + "line": 9, + "column": 18, + "end_line": 9, + "end_column": 22 } }, "filename": "type-01.k", @@ -391,59 +376,57 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ - { - "node": "type_list3", - "filename": "type-01.k", - "line": 10, - "column": 5, - "end_line": 10, - "end_column": 15 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 10, - "column": 5, - "end_line": 10, - "end_column": 15 - }, - "type_value": { - "node": "[int]", - "filename": "type-01.k", - "line": 10, - "column": 18, - "end_line": 10, - "end_column": 23 + "type_name": { + "node": { + "names": [ + { + "node": "type_list3", + "filename": "type-01.k", + "line": 10, + "column": 5, + "end_line": 10, + "end_column": 15 + } + ], + "pkgpath": "", + "ctx": "Load" }, - "ty": { - "node": { - "type": "List", - "data": { - "inner_type": { - "node": { - "type": "Basic", - "data": "Int" - }, - "filename": "type-01.k", - "line": 10, - "column": 19, - "end_line": 10, - "end_column": 22 - } + "filename": "type-01.k", + "line": 10, + "column": 5, + "end_line": 10, + "end_column": 15 + }, + "type_value": { + "node": "[int]", + "filename": "type-01.k", + "line": 10, + "column": 18, + "end_line": 10, + "end_column": 23 + }, + "ty": { + "node": { + "type": "List", + "value": { + "inner_type": { + "node": { + "type": "Basic", + "value": "Int" + }, + "filename": "type-01.k", + "line": 10, + "column": 19, + "end_line": 10, + "end_column": 22 } - }, - "filename": "type-01.k", - "line": 10, - "column": 18, - "end_line": 10, - "end_column": 23 - } + } + }, + "filename": "type-01.k", + "line": 10, + "column": 18, + "end_line": 10, + "end_column": 23 } }, "filename": "type-01.k", @@ -455,99 +438,97 @@ expression: "crate::tests::parsing_file_string(\"testdata/type-01.k\")" { "node": { "type": "TypeAlias", - "data": { - "type_name": { - "node": { - "names": [ + "type_name": { + "node": { + "names": [ + { + "node": "b", + "filename": "type-01.k", + "line": 12, + "column": 5, + "end_line": 12, + "end_column": 6 + } + ], + "pkgpath": "", + "ctx": "Load" + }, + "filename": "type-01.k", + "line": 12, + "column": 5, + "end_line": 12, + "end_column": 6 + }, + "type_value": { + "node": "int | str | [] | {:}", + "filename": "type-01.k", + "line": 12, + "column": 9, + "end_line": 12, + "end_column": 29 + }, + "ty": { + "node": { + "type": "Union", + "value": { + "type_elements": [ { - "node": "b", + "node": { + "type": "Basic", + "value": "Int" + }, "filename": "type-01.k", "line": 12, - "column": 5, + "column": 9, "end_line": 12, - "end_column": 6 - } - ], - "pkgpath": "", - "ctx": "Load" - }, - "filename": "type-01.k", - "line": 12, - "column": 5, - "end_line": 12, - "end_column": 6 - }, - "type_value": { - "node": "int | str | [] | {:}", - "filename": "type-01.k", - "line": 12, - "column": 9, - "end_line": 12, - "end_column": 29 - }, - "ty": { - "node": { - "type": "Union", - "data": { - "type_elements": [ - { - "node": { - "type": "Basic", - "data": "Int" - }, - "filename": "type-01.k", - "line": 12, - "column": 9, - "end_line": 12, - "end_column": 12 + "end_column": 12 + }, + { + "node": { + "type": "Basic", + "value": "Str" }, - { - "node": { - "type": "Basic", - "data": "Str" - }, - "filename": "type-01.k", - "line": 12, - "column": 15, - "end_line": 12, - "end_column": 18 + "filename": "type-01.k", + "line": 12, + "column": 15, + "end_line": 12, + "end_column": 18 + }, + { + "node": { + "type": "List", + "value": { + "inner_type": null + } }, - { - "node": { - "type": "List", - "data": { - "inner_type": null - } - }, - "filename": "type-01.k", - "line": 12, - "column": 21, - "end_line": 12, - "end_column": 23 + "filename": "type-01.k", + "line": 12, + "column": 21, + "end_line": 12, + "end_column": 23 + }, + { + "node": { + "type": "Dict", + "value": { + "key_type": null, + "value_type": null + } }, - { - "node": { - "type": "Dict", - "data": { - "key_type": null, - "value_type": null - } - }, - "filename": "type-01.k", - "line": 12, - "column": 26, - "end_line": 12, - "end_column": 29 - } - ] - } - }, - "filename": "type-01.k", - "line": 12, - "column": 9, - "end_line": 12, - "end_column": 29 - } + "filename": "type-01.k", + "line": 12, + "column": 26, + "end_line": 12, + "end_column": 29 + } + ] + } + }, + "filename": "type-01.k", + "line": 12, + "column": 9, + "end_line": 12, + "end_column": 29 } }, "filename": "type-01.k", diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__any_type.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__any_type.snap index 82c85bae7..5e3e41d28 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__any_type.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__any_type.snap @@ -2,5 +2,12 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"any\"####)" --- -Node { node: Any, filename: "", line: 1, column: 0, end_line: 1, end_column: 3 } +Node { + node: Any, + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 3, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_0.snap index 0278843ab..d7a243058 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_0.snap @@ -2,5 +2,14 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"bool\"####)" --- -Node { node: Basic(Bool), filename: "", line: 1, column: 0, end_line: 1, end_column: 4 } +Node { + node: Basic( + Bool, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 4, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_1.snap index a1e2bf120..335b19217 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_1.snap @@ -2,5 +2,14 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"int\"####)" --- -Node { node: Basic(Int), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 } +Node { + node: Basic( + Int, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 3, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_2.snap index 050eeed43..7c6ee89d2 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_2.snap @@ -2,5 +2,14 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"float\"####)" --- -Node { node: Basic(Float), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } +Node { + node: Basic( + Float, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_3.snap index 36be5555c..9d7b59a4b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__basic_type_3.snap @@ -2,5 +2,14 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"str\"####)" --- -Node { node: Basic(Str), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 } +Node { + node: Basic( + Str, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 3, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_0.snap index 7ee365471..7d0a2bf4b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_0.snap @@ -2,5 +2,17 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"{:}\"####)" --- -Node { node: Dict(DictType { key_type: None, value_type: None }), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 } +Node { + node: Dict( + DictType { + key_type: None, + value_type: None, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 3, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_1.snap index 4c8cc46fb..3b4667dcb 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_1.snap @@ -2,5 +2,28 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"{str:}\"####)" --- -Node { node: Dict(DictType { key_type: Some(Node { node: Basic(Str), filename: "", line: 1, column: 1, end_line: 1, end_column: 4 }), value_type: None }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 } +Node { + node: Dict( + DictType { + key_type: Some( + Node { + node: Basic( + Str, + ), + filename: "", + line: 1, + column: 1, + end_line: 1, + end_column: 4, + }, + ), + value_type: None, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 6, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_2.snap index d60382838..8165aaed5 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_2.snap @@ -2,5 +2,30 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"{:[]}\"####)" --- -Node { node: Dict(DictType { key_type: None, value_type: Some(Node { node: List(ListType { inner_type: None }), filename: "", line: 1, column: 2, end_line: 1, end_column: 4 }) }), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } +Node { + node: Dict( + DictType { + key_type: None, + value_type: Some( + Node { + node: List( + ListType { + inner_type: None, + }, + ), + filename: "", + line: 1, + column: 2, + end_line: 1, + end_column: 4, + }, + ), + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_3.snap index f7a89090d..c35fb6168 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_3.snap @@ -2,5 +2,53 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"{str:{:float}}\"####)" --- -Node { node: Dict(DictType { key_type: Some(Node { node: Basic(Str), filename: "", line: 1, column: 1, end_line: 1, end_column: 4 }), value_type: Some(Node { node: Dict(DictType { key_type: None, value_type: Some(Node { node: Basic(Float), filename: "", line: 1, column: 7, end_line: 1, end_column: 12 }) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 13 }) }), filename: "", line: 1, column: 0, end_line: 1, end_column: 14 } +Node { + node: Dict( + DictType { + key_type: Some( + Node { + node: Basic( + Str, + ), + filename: "", + line: 1, + column: 1, + end_line: 1, + end_column: 4, + }, + ), + value_type: Some( + Node { + node: Dict( + DictType { + key_type: None, + value_type: Some( + Node { + node: Basic( + Float, + ), + filename: "", + line: 1, + column: 7, + end_line: 1, + end_column: 12, + }, + ), + }, + ), + filename: "", + line: 1, + column: 5, + end_line: 1, + end_column: 13, + }, + ), + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 14, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_4.snap index 3529c1f71..b98aafcde 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__dict_type_4.snap @@ -2,5 +2,53 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"{str:{:float}, int:[]}\"####)" --- -Node { node: Dict(DictType { key_type: Some(Node { node: Basic(Str), filename: "", line: 1, column: 1, end_line: 1, end_column: 4 }), value_type: Some(Node { node: Dict(DictType { key_type: None, value_type: Some(Node { node: Basic(Float), filename: "", line: 1, column: 7, end_line: 1, end_column: 12 }) }), filename: "", line: 1, column: 5, end_line: 1, end_column: 13 }) }), filename: "", line: 1, column: 0, end_line: 1, end_column: 14 } +Node { + node: Dict( + DictType { + key_type: Some( + Node { + node: Basic( + Str, + ), + filename: "", + line: 1, + column: 1, + end_line: 1, + end_column: 4, + }, + ), + value_type: Some( + Node { + node: Dict( + DictType { + key_type: None, + value_type: Some( + Node { + node: Basic( + Float, + ), + filename: "", + line: 1, + column: 7, + end_line: 1, + end_column: 12, + }, + ), + }, + ), + filename: "", + line: 1, + column: 5, + end_line: 1, + end_column: 13, + }, + ), + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 14, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_0.snap index 92d5a957d..c473941af 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_0.snap @@ -2,5 +2,16 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"[]\"####)" --- -Node { node: List(ListType { inner_type: None }), filename: "", line: 1, column: 0, end_line: 1, end_column: 2 } +Node { + node: List( + ListType { + inner_type: None, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 2, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_1.snap index f5953cbcf..fd9988b84 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_1.snap @@ -2,5 +2,27 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"[int]\"####)" --- -Node { node: List(ListType { inner_type: Some(Node { node: Basic(Int), filename: "", line: 1, column: 1, end_line: 1, end_column: 4 }) }), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } +Node { + node: List( + ListType { + inner_type: Some( + Node { + node: Basic( + Int, + ), + filename: "", + line: 1, + column: 1, + end_line: 1, + end_column: 4, + }, + ), + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_2.snap index 3d65a2b95..73e992119 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_2.snap @@ -2,5 +2,25 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"[any]\"####)" --- -Node { node: List(ListType { inner_type: Some(Node { node: Any, filename: "", line: 1, column: 1, end_line: 1, end_column: 4 }) }), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } +Node { + node: List( + ListType { + inner_type: Some( + Node { + node: Any, + filename: "", + line: 1, + column: 1, + end_line: 1, + end_column: 4, + }, + ), + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_3.snap index b8179378e..a3b930896 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_3.snap @@ -2,5 +2,29 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"[[]]\"####)" --- -Node { node: List(ListType { inner_type: Some(Node { node: List(ListType { inner_type: None }), filename: "", line: 1, column: 1, end_line: 1, end_column: 3 }) }), filename: "", line: 1, column: 0, end_line: 1, end_column: 4 } +Node { + node: List( + ListType { + inner_type: Some( + Node { + node: List( + ListType { + inner_type: None, + }, + ), + filename: "", + line: 1, + column: 1, + end_line: 1, + end_column: 3, + }, + ), + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 4, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_4.snap index 6be62054b..518dd31b9 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__list_type_4.snap @@ -2,5 +2,40 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"[[str]]\"####)" --- -Node { node: List(ListType { inner_type: Some(Node { node: List(ListType { inner_type: Some(Node { node: Basic(Str), filename: "", line: 1, column: 2, end_line: 1, end_column: 5 }) }), filename: "", line: 1, column: 1, end_line: 1, end_column: 6 }) }), filename: "", line: 1, column: 0, end_line: 1, end_column: 7 } +Node { + node: List( + ListType { + inner_type: Some( + Node { + node: List( + ListType { + inner_type: Some( + Node { + node: Basic( + Str, + ), + filename: "", + line: 1, + column: 2, + end_line: 1, + end_column: 5, + }, + ), + }, + ), + filename: "", + line: 1, + column: 1, + end_line: 1, + end_column: 6, + }, + ), + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 7, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_0.snap index 4e96bc209..d7ba0c795 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_0.snap @@ -2,5 +2,16 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"True\"####)" --- -Node { node: Literal(Bool(true)), filename: "", line: 1, column: 0, end_line: 1, end_column: 4 } +Node { + node: Literal( + Bool( + true, + ), + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 4, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_1.snap index 1ea1a4aaa..79951d904 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_1.snap @@ -2,5 +2,16 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"False\"####)" --- -Node { node: Literal(Bool(false)), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } +Node { + node: Literal( + Bool( + false, + ), + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_2.snap index 412c2daa5..fe221ef16 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_2.snap @@ -2,5 +2,19 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"123\"####)" --- -Node { node: Literal(Int(123, None)), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 } +Node { + node: Literal( + Int( + IntLiteralType { + value: 123, + suffix: None, + }, + ), + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 3, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_3.snap index d70e4b2ce..7db780a7d 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_3.snap @@ -2,5 +2,16 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"123.0\"####)" --- -Node { node: Literal(Float(123.0)), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } +Node { + node: Literal( + Float( + 123.0, + ), + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_4.snap index 8b5bbed08..9e368bc0d 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_4.snap @@ -2,5 +2,16 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"\"abc\"\"####)" --- -Node { node: Literal(Str("abc")), filename: "", line: 1, column: 0, end_line: 1, end_column: 5 } +Node { + node: Literal( + Str( + "abc", + ), + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 5, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_5.snap index c6e30c431..886d9b0cb 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__literal_type_5.snap @@ -2,5 +2,16 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"''\"####)" --- -Node { node: Literal(Str("")), filename: "", line: 1, column: 0, end_line: 1, end_column: 2 } +Node { + node: Literal( + Str( + "", + ), + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 2, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_0.snap index a2a929e53..9c2a9e0a9 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_0.snap @@ -2,5 +2,27 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"Person\"####)" --- -Node { node: Named(Identifier { names: [Node { node: "Person", filename: "", line: 1, column: 0, end_line: 1, end_column: 6 }], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 6 } +Node { + node: Named( + Identifier { + names: [ + Node { + node: "Person", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 6, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 6, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_1.snap index 2552edc9b..ea918caae 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__named_type_1.snap @@ -2,5 +2,43 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"some.pkg.Person\"####)" --- -Node { node: Named(Identifier { names: [Node { node: "some", filename: "", line: 1, column: 0, end_line: 1, end_column: 4 }, Node { node: "pkg", filename: "", line: 1, column: 5, end_line: 1, end_column: 8 }, Node { node: "Person", filename: "", line: 1, column: 9, end_line: 1, end_column: 15 }], pkgpath: "", ctx: Load }), filename: "", line: 1, column: 0, end_line: 1, end_column: 15 } +Node { + node: Named( + Identifier { + names: [ + Node { + node: "some", + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 4, + }, + Node { + node: "pkg", + filename: "", + line: 1, + column: 5, + end_line: 1, + end_column: 8, + }, + Node { + node: "Person", + filename: "", + line: 1, + column: 9, + end_line: 1, + end_column: 15, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 15, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_0.snap index 89a015a32..d78b2e820 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_0.snap @@ -2,5 +2,37 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"int|str\"####)" --- -Node { node: Union(UnionType { type_elements: [Node { node: Basic(Int), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 }, Node { node: Basic(Str), filename: "", line: 1, column: 4, end_line: 1, end_column: 7 }] }), filename: "", line: 1, column: 0, end_line: 1, end_column: 7 } +Node { + node: Union( + UnionType { + type_elements: [ + Node { + node: Basic( + Int, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 3, + }, + Node { + node: Basic( + Str, + ), + filename: "", + line: 1, + column: 4, + end_line: 1, + end_column: 7, + }, + ], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 7, +} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_1.snap index 040a35f0c..4a631d87f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__types__union_type_1.snap @@ -2,5 +2,62 @@ source: parser/src/tests/types.rs expression: "crate::tests::parsing_type_string(r####\"int | str | [] | {:}\"####)" --- -Node { node: Union(UnionType { type_elements: [Node { node: Basic(Int), filename: "", line: 1, column: 0, end_line: 1, end_column: 3 }, Node { node: Basic(Str), filename: "", line: 1, column: 6, end_line: 1, end_column: 9 }, Node { node: List(ListType { inner_type: None }), filename: "", line: 1, column: 12, end_line: 1, end_column: 14 }, Node { node: Dict(DictType { key_type: None, value_type: None }), filename: "", line: 1, column: 17, end_line: 1, end_column: 20 }] }), filename: "", line: 1, column: 0, end_line: 1, end_column: 20 } +Node { + node: Union( + UnionType { + type_elements: [ + Node { + node: Basic( + Int, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 3, + }, + Node { + node: Basic( + Str, + ), + filename: "", + line: 1, + column: 6, + end_line: 1, + end_column: 9, + }, + Node { + node: List( + ListType { + inner_type: None, + }, + ), + filename: "", + line: 1, + column: 12, + end_line: 1, + end_column: 14, + }, + Node { + node: Dict( + DictType { + key_type: None, + value_type: None, + }, + ), + filename: "", + line: 1, + column: 17, + end_line: 1, + end_column: 20, + }, + ], + }, + ), + filename: "", + line: 1, + column: 0, + end_line: 1, + end_column: 20, +} diff --git a/kclvm/sema/src/resolver/node.rs b/kclvm/sema/src/resolver/node.rs index 6b27bf96d..22c43184d 100644 --- a/kclvm/sema/src/resolver/node.rs +++ b/kclvm/sema/src/resolver/node.rs @@ -401,7 +401,7 @@ impl<'ctx> MutSelfTypedResultWalker<'ctx> for Resolver<'ctx> { match &schema_attr.op { Some(bin_or_aug) => match bin_or_aug { // Union - ast::BinOrAugOp::Aug(ast::AugOp::BitOr) => { + ast::AugOp::BitOr => { let op = ast::BinOp::BitOr; let value_ty = self.binary( value_ty, @@ -451,37 +451,42 @@ impl<'ctx> MutSelfTypedResultWalker<'ctx> for Resolver<'ctx> { let left_ty = self.expr(&binary_expr.left); let mut right_ty = self.expr(&binary_expr.right); match &binary_expr.op { - ast::BinOrCmpOp::Bin(bin_op) => match bin_op { - ast::BinOp::As => { - if let ast::Expr::Identifier(identifier) = &binary_expr.right.node { - right_ty = self.parse_ty_str_with_scope( - &identifier.get_name(), - binary_expr.right.get_span_pos(), - ); - if right_ty.is_schema() { - let mut schema_ty = right_ty.into_schema_type(); - schema_ty.is_instance = true; - right_ty = Arc::new(Type::schema(schema_ty)); - } - let ty_annotation_str = right_ty.into_type_annotation_str(); - self.add_type_alias( - &identifier.get_name(), - &ty_str_replace_pkgpath(&ty_annotation_str, &self.ctx.pkgpath), - ); - } else { - self.handler.add_compile_error( - "keyword 'as' right operand must be a type", - binary_expr.left.get_span_pos(), - ); - return left_ty; + ast::BinOp::As => { + if let ast::Expr::Identifier(identifier) = &binary_expr.right.node { + right_ty = self.parse_ty_str_with_scope( + &identifier.get_name(), + binary_expr.right.get_span_pos(), + ); + if right_ty.is_schema() { + let mut schema_ty = right_ty.into_schema_type(); + schema_ty.is_instance = true; + right_ty = Arc::new(Type::schema(schema_ty)); } - self.binary(left_ty, right_ty, bin_op, binary_expr.left.get_span_pos()) + let ty_annotation_str = right_ty.into_type_annotation_str(); + self.add_type_alias( + &identifier.get_name(), + &ty_str_replace_pkgpath(&ty_annotation_str, &self.ctx.pkgpath), + ); + } else { + self.handler.add_compile_error( + "keyword 'as' right operand must be a type", + binary_expr.left.get_span_pos(), + ); + return left_ty; } - _ => self.binary(left_ty, right_ty, bin_op, binary_expr.left.get_span_pos()), - }, - ast::BinOrCmpOp::Cmp(cmp_op) => { - self.compare(left_ty, right_ty, cmp_op, binary_expr.left.get_span_pos()) + self.binary( + left_ty, + right_ty, + &binary_expr.op, + binary_expr.left.get_span_pos(), + ) } + _ => self.binary( + left_ty, + right_ty, + &binary_expr.op, + binary_expr.left.get_span_pos(), + ), } } diff --git a/kclvm/sema/src/ty/into.rs b/kclvm/sema/src/ty/into.rs index 0ae29f180..f73fb9327 100644 --- a/kclvm/sema/src/ty/into.rs +++ b/kclvm/sema/src/ty/into.rs @@ -156,7 +156,10 @@ impl From for Type { ), ast::Type::Literal(literal_ty) => match literal_ty { ast::LiteralType::Bool(v) => Type::bool_lit(v), - ast::LiteralType::Int(v, suffix_option) => match suffix_option { + ast::LiteralType::Int(ast::IntLiteralType { + value: v, + suffix: suffix_option, + }) => match suffix_option { Some(suffix) => Type::number_multiplier( kclvm_runtime::cal_num(v, &suffix.value()), v, diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-2.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-2.snap index b152b25a5..6c792a219 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-2.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-2.snap @@ -9,168 +9,152 @@ expression: got_ast_json_str "filename": "/simple.k.json", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "/simple.k.json", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 5, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, "filename": "/simple.k.json", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "/simple.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "/simple.k.json", - "line": 3, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" - } - } + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" } }, - { - "column": 0, - "end_column": 1, - "end_line": 5, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, "filename": "/simple.k.json", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "/simple.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 15, - "end_column": 30, - "end_line": 4, - "filename": "/simple.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" - } + "type": "Int", + "value": 18 } } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, + "filename": "/simple.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" + } }, - { - "column": 0, - "end_column": 1, - "end_line": 5, + "operation": "Union", + "value": { + "column": 15, + "end_column": 30, + "end_line": 4, "filename": "/simple.k.json", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/simple.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 19, - "end_line": 2, - "filename": "/simple.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" } } - ] + } }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "/simple.k.json", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "/simple.k.json", - "line": 1, - "node": "simple" + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "/simple.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 19, + "end_line": 2, + "filename": "/simple.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" + } + } } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": "simple" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-3.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-3.snap index c0a67c0ca..19165aa64 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-3.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-3.snap @@ -9,13 +9,11 @@ expression: got_ast_json_str "filename": "/plain_value.k.json", "line": 1, "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 + } } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-4.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-4.snap index f6da78b6f..71c682689 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-4.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-4.snap @@ -9,185 +9,167 @@ expression: got_ast_json_str "filename": "/list.k.json", "line": 1, "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "/list.k.json", - "line": 2, - "node": { - "data": { - "args": [], - "config": { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "/list.k.json", - "line": 2, - "node": { - "data": { - "items": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "/list.k.json", - "line": 2, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 13, - "end_line": 4, - "filename": "/list.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 17, - "end_line": 4, - "filename": "/list.k.json", - "line": 4, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" - } - } - } - }, - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "/list.k.json", - "line": 2, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 17, - "end_line": 5, - "filename": "/list.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 19, - "end_column": 34, - "end_line": 5, - "filename": "/list.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" - } - } - } - }, - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "/list.k.json", - "line": 2, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 14, - "end_line": 3, - "filename": "/list.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 16, - "end_column": 23, - "end_line": 3, - "filename": "/list.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } - } + "ctx": "Load", + "elts": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "args": [], + "config": { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "items": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 13, + "end_line": 4, + "filename": "/list.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 17, + "end_line": 4, + "filename": "/list.k.json", + "line": 4, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 18 } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "/list.k.json", - "line": 2, - "node": { - "ctx": "Load", - "names": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, + } + } + }, + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 17, + "end_line": 5, + "filename": "/list.k.json", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" + } + }, + "operation": "Union", + "value": { + "column": 19, + "end_column": 34, + "end_line": 5, + "filename": "/list.k.json", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" + } + } + } + }, + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 14, + "end_line": 3, "filename": "/list.k.json", - "line": 2, - "node": "list" + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 16, + "end_column": 23, + "end_line": 3, + "filename": "/list.k.json", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" + } } - ], - "pkgpath": "" + } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "ctx": "Load", + "names": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": "list" } - } - }, - "type": "Schema" - } + ], + "pkgpath": "" + } + }, + "type": "Schema" } - ] - }, + } + ], "type": "List" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-5.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-5.snap index 43900de05..eae68d196 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-5.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-5.snap @@ -9,465 +9,419 @@ expression: got_ast_json_str "filename": "/complex.k.json", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 13, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, "filename": "/complex.k.json", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "/complex.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "/complex.k.json", - "line": 3, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" - } - } + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, "filename": "/complex.k.json", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 5, - "filename": "/complex.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"data\"", - "value": "data" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 12, - "end_column": 5, - "end_line": 8, - "filename": "/complex.k.json", - "line": 5, - "node": { - "data": { - "items": [ - { - "column": 12, - "end_column": 5, - "end_line": 8, - "filename": "/complex.k.json", - "line": 5, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 12, - "end_line": 6, - "filename": "/complex.k.json", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"id\"", - "value": "id" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 15, - "end_line": 6, - "filename": "/complex.k.json", - "line": 6, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" - } - } - } - }, - { - "column": 12, - "end_column": 5, - "end_line": 8, - "filename": "/complex.k.json", - "line": 5, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 15, - "end_line": 7, - "filename": "/complex.k.json", - "line": 7, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value\"", - "value": "value" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 17, - "end_column": 25, - "end_line": 7, - "filename": "/complex.k.json", - "line": 7, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value1\"", - "value": "value1" - }, - "type": "StringLit" - } - } - } - } - ] - }, - "type": "Config" - } + "type": "Int", + "value": 18 } } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 5, + "filename": "/complex.k.json", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"data\"", + "type": "StringLit", + "value": "data" + } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 12, + "end_column": 5, + "end_line": 8, "filename": "/complex.k.json", - "line": 1, + "line": 5, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 8, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"hc\"", - "value": "hc" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 10, - "end_column": 19, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 11, - "end_column": 12, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" - } - }, - { - "column": 14, - "end_column": 15, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 2, - "type": "Int" - } - }, - "type": "NumberLit" - } - }, - { - "column": 17, - "end_column": 18, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 3, - "type": "Int" - } - }, - "type": "NumberLit" + "items": [ + { + "column": 12, + "end_column": 5, + "end_line": 8, + "filename": "/complex.k.json", + "line": 5, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 12, + "end_line": 6, + "filename": "/complex.k.json", + "line": 6, + "node": { + "is_long_string": false, + "raw_value": "\"id\"", + "type": "StringLit", + "value": "id" + } + }, + "operation": "Union", + "value": { + "column": 14, + "end_column": 15, + "end_line": 6, + "filename": "/complex.k.json", + "line": 6, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 } } - ] - }, - "type": "List" + } + } + }, + { + "column": 12, + "end_column": 5, + "end_line": 8, + "filename": "/complex.k.json", + "line": 5, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 15, + "end_line": 7, + "filename": "/complex.k.json", + "line": 7, + "node": { + "is_long_string": false, + "raw_value": "\"value\"", + "type": "StringLit", + "value": "value" + } + }, + "operation": "Union", + "value": { + "column": 17, + "end_column": 25, + "end_line": 7, + "filename": "/complex.k.json", + "line": 7, + "node": { + "is_long_string": false, + "raw_value": "\"value1\"", + "type": "StringLit", + "value": "value1" + } + } + } } - } + ], + "type": "Config" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 8, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "is_long_string": false, + "raw_value": "\"hc\"", + "type": "StringLit", + "value": "hc" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 10, + "end_column": 19, + "end_line": 12, "filename": "/complex.k.json", - "line": 1, + "line": 12, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 12, - "end_line": 9, - "filename": "/complex.k.json", - "line": 9, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"labels\"", - "value": "labels" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "/complex.k.json", - "line": 9, - "node": { - "data": { - "items": [ - { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "/complex.k.json", - "line": 9, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 13, - "end_line": 10, - "filename": "/complex.k.json", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"key\"", - "value": "key" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 22, - "end_line": 10, - "filename": "/complex.k.json", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value\"", - "value": "value" - }, - "type": "StringLit" - } - } - } - } - ] - }, - "type": "Config" + "ctx": "Load", + "elts": [ + { + "column": 11, + "end_column": 12, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 + } + } + }, + { + "column": 14, + "end_column": 15, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 2 + } + } + }, + { + "column": 17, + "end_column": 18, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 3 + } + } } - } + ], + "type": "List" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 12, + "end_line": 9, + "filename": "/complex.k.json", + "line": 9, + "node": { + "is_long_string": false, + "raw_value": "\"labels\"", + "type": "StringLit", + "value": "labels" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 14, + "end_column": 5, + "end_line": 11, "filename": "/complex.k.json", - "line": 1, + "line": 9, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "/complex.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 30, - "end_line": 4, - "filename": "/complex.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" + "items": [ + { + "column": 14, + "end_column": 5, + "end_line": 11, + "filename": "/complex.k.json", + "line": 9, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 13, + "end_line": 10, + "filename": "/complex.k.json", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"key\"", + "type": "StringLit", + "value": "key" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 22, + "end_line": 10, + "filename": "/complex.k.json", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"value\"", + "type": "StringLit", + "value": "value" + } + } + } } - } + ], + "type": "Config" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, + "filename": "/complex.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 15, + "end_column": 30, + "end_line": 4, "filename": "/complex.k.json", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/complex.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 19, - "end_line": 2, - "filename": "/complex.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" } } - ] + } }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": "complex" + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "/complex.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 19, + "end_line": 2, + "filename": "/complex.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" + } + } } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": "complex" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-6.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-6.snap index 3f1c948fc..0ac707bcd 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-6.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-6.snap @@ -9,82 +9,74 @@ expression: got_ast_json_str "filename": "/only_with_null.json", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_null.json", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_null.json", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_null.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 16, + "end_line": 2, "filename": "/only_with_null.json", - "line": 1, + "line": 2, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 16, - "end_line": 2, - "filename": "/only_with_null.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"null_value\"", - "value": "null_value" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 18, - "end_column": 22, - "end_line": 2, - "filename": "/only_with_null.json", - "line": 2, - "node": { - "data": { - "value": "None" - }, - "type": "NameConstantLit" - } - } + "is_long_string": false, + "raw_value": "\"null_value\"", + "type": "StringLit", + "value": "null_value" + } + }, + "operation": "Union", + "value": { + "column": 18, + "end_column": 22, + "end_line": 2, + "filename": "/only_with_null.json", + "line": 2, + "node": { + "type": "NameConstantLit", + "value": "None" } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_null.json", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_null.json", - "line": 1, - "node": "only_with_null" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_null.json", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_null.json", + "line": 1, + "node": "only_with_null" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-7.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-7.snap index e430214ea..1dbe63aa9 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-7.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-7.snap @@ -9,82 +9,74 @@ expression: got_ast_json_str "filename": "/only_with_bool.json", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_bool.json", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_bool.json", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_bool.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, "filename": "/only_with_bool.json", - "line": 1, + "line": 2, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/only_with_bool.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"flag\"", - "value": "flag" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 16, - "end_line": 2, - "filename": "/only_with_bool.json", - "line": 2, - "node": { - "data": { - "value": "True" - }, - "type": "NameConstantLit" - } - } + "is_long_string": false, + "raw_value": "\"flag\"", + "type": "StringLit", + "value": "flag" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 16, + "end_line": 2, + "filename": "/only_with_bool.json", + "line": 2, + "node": { + "type": "NameConstantLit", + "value": "True" } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_bool.json", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_bool.json", - "line": 1, - "node": "only_with_bool" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_bool.json", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_bool.json", + "line": 1, + "node": "only_with_bool" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-8.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-8.snap index 43d2bbb61..e508aac19 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-8.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath-8.snap @@ -9,86 +9,78 @@ expression: got_ast_json_str "filename": "/only_with_float.json", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_float.json", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_float.json", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_float.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 17, + "end_line": 2, "filename": "/only_with_float.json", - "line": 1, + "line": 2, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 17, - "end_line": 2, - "filename": "/only_with_float.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"float_value\"", - "value": "float_value" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "is_long_string": false, + "raw_value": "\"float_value\"", + "type": "StringLit", + "value": "float_value" + } + }, + "operation": "Union", + "value": { + "column": 19, + "end_column": 23, + "end_line": 2, + "filename": "/only_with_float.json", + "line": 2, + "node": { + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 19, - "end_column": 23, - "end_line": 2, - "filename": "/only_with_float.json", - "line": 2, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 0.33, - "type": "Float" - } - }, - "type": "NumberLit" - } + "type": "Float", + "value": 0.33 } } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_float.json", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_float.json", - "line": 1, - "node": "only_with_float" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_float.json", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_float.json", + "line": 1, + "node": "only_with_float" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath.snap index ca6062cef..376279697 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_filepath.snap @@ -1,6 +1,5 @@ --- source: tools/src/vet/tests.rs -assertion_line: 215 expression: got_ast_json_str --- { @@ -10,320 +9,288 @@ expression: got_ast_json_str "filename": "/test.k.json", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "/test.k.json", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 12, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, "filename": "/test.k.json", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "/test.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"address\"", - "value": "address" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 5, - "end_line": 7, - "filename": "/test.k.json", - "line": 4, - "node": { - "data": { - "items": [ - { - "column": 15, - "end_column": 5, - "end_line": 7, - "filename": "/test.k.json", - "line": 4, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 14, - "end_line": 6, - "filename": "/test.k.json", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"city\"", - "value": "city" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 16, - "end_column": 24, - "end_line": 6, - "filename": "/test.k.json", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"London\"", - "value": "London" - }, - "type": "StringLit" - } - } - } - }, - { - "column": 15, - "end_column": 5, - "end_line": 7, - "filename": "/test.k.json", - "line": 4, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 16, - "end_line": 5, - "filename": "/test.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"street\"", - "value": "street" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 18, - "end_column": 37, - "end_line": 5, - "filename": "/test.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"10 Downing Street\"", - "value": "10 Downing Street" - }, - "type": "StringLit" - } - } - } - } - ] - }, - "type": "Config" - } - } + "is_long_string": false, + "raw_value": "\"address\"", + "type": "StringLit", + "value": "address" } }, - { - "column": 0, - "end_column": 1, - "end_line": 12, + "operation": "Union", + "value": { + "column": 15, + "end_column": 5, + "end_line": 7, "filename": "/test.k.json", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "/test.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "/test.k.json", - "line": 3, - "node": { - "data": { - "binary_suffix": null, + "items": [ + { + "column": 15, + "end_column": 5, + "end_line": 7, + "filename": "/test.k.json", + "line": 4, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 14, + "end_line": 6, + "filename": "/test.k.json", + "line": 6, + "node": { + "is_long_string": false, + "raw_value": "\"city\"", + "type": "StringLit", + "value": "city" + } + }, + "operation": "Union", "value": { - "data": 43, - "type": "Int" + "column": 16, + "end_column": 24, + "end_line": 6, + "filename": "/test.k.json", + "line": 6, + "node": { + "is_long_string": false, + "raw_value": "\"London\"", + "type": "StringLit", + "value": "London" + } } - }, - "type": "NumberLit" + } + }, + { + "column": 15, + "end_column": 5, + "end_line": 7, + "filename": "/test.k.json", + "line": 4, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 16, + "end_line": 5, + "filename": "/test.k.json", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"street\"", + "type": "StringLit", + "value": "street" + } + }, + "operation": "Union", + "value": { + "column": 18, + "end_column": 37, + "end_line": 5, + "filename": "/test.k.json", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"10 Downing Street\"", + "type": "StringLit", + "value": "10 Downing Street" + } + } + } } - } + ], + "type": "Config" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, + "filename": "/test.k.json", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" } }, - { - "column": 0, - "end_column": 1, - "end_line": 12, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, "filename": "/test.k.json", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/test.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 12, - "end_column": 22, - "end_line": 2, - "filename": "/test.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"John Doe\"", - "value": "John Doe" - }, - "type": "StringLit" - } + "type": "Int", + "value": 43 } } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "/test.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } }, - { - "column": 0, - "end_column": 1, - "end_line": 12, + "operation": "Union", + "value": { + "column": 12, + "end_column": 22, + "end_line": 2, + "filename": "/test.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"John Doe\"", + "type": "StringLit", + "value": "John Doe" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 12, + "end_line": 8, "filename": "/test.k.json", - "line": 1, + "line": 8, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 12, - "end_line": 8, - "filename": "/test.k.json", - "line": 8, - "node": { - "data": { + "is_long_string": false, + "raw_value": "\"phones\"", + "type": "StringLit", + "value": "phones" + } + }, + "operation": "Union", + "value": { + "column": 14, + "end_column": 5, + "end_line": 11, + "filename": "/test.k.json", + "line": 8, + "node": { + "ctx": "Load", + "elts": [ + { + "column": 8, + "end_column": 21, + "end_line": 9, + "filename": "/test.k.json", + "line": 9, + "node": { "is_long_string": false, - "raw_value": "\"phones\"", - "value": "phones" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "/test.k.json", - "line": 8, - "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 8, - "end_column": 21, - "end_line": 9, - "filename": "/test.k.json", - "line": 9, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"+44 1234567\"", - "value": "+44 1234567" - }, - "type": "StringLit" - } - }, - { - "column": 8, - "end_column": 21, - "end_line": 10, - "filename": "/test.k.json", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"+44 2345678\"", - "value": "+44 2345678" - }, - "type": "StringLit" - } - } - ] - }, - "type": "List" + "raw_value": "\"+44 1234567\"", + "type": "StringLit", + "value": "+44 1234567" + } + }, + { + "column": 8, + "end_column": 21, + "end_line": 10, + "filename": "/test.k.json", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"+44 2345678\"", + "type": "StringLit", + "value": "+44 2345678" + } } - } + ], + "type": "List" } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "/test.k.json", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "/test.k.json", - "line": 1, - "node": "test" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": "test" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-2.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-2.snap index 79977221b..9d6105035 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-2.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-2.snap @@ -9,168 +9,152 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 5, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, "filename": "", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" - } - } + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" } }, - { - "column": 0, - "end_column": 1, - "end_line": 5, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, "filename": "", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 15, - "end_column": 30, - "end_line": 4, - "filename": "", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" - } + "type": "Int", + "value": 18 } } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, + "filename": "", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" + } }, - { - "column": 0, - "end_column": 1, - "end_line": 5, + "operation": "Union", + "value": { + "column": 15, + "end_column": 30, + "end_line": 4, "filename": "", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 19, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" } } - ] + } }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "", - "line": 1, - "node": "simple" + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 19, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" + } + } } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "", + "line": 1, + "node": "simple" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-3.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-3.snap index 2c8b0b66f..1d2ef3c01 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-3.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-3.snap @@ -9,13 +9,11 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 + } } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-4.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-4.snap index 0408509ad..a5b616a7e 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-4.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-4.snap @@ -9,185 +9,167 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "", - "line": 2, - "node": { - "data": { - "args": [], - "config": { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "", - "line": 2, - "node": { - "data": { - "items": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "", - "line": 2, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 13, - "end_line": 4, - "filename": "", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 17, - "end_line": 4, - "filename": "", - "line": 4, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" - } - } - } - }, - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "", - "line": 2, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 17, - "end_line": 5, - "filename": "", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 19, - "end_column": 34, - "end_line": 5, - "filename": "", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" - } - } - } - }, - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "", - "line": 2, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 14, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 16, - "end_column": 23, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } - } + "ctx": "Load", + "elts": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "", + "line": 2, + "node": { + "args": [], + "config": { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "", + "line": 2, + "node": { + "items": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 13, + "end_line": 4, + "filename": "", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 17, + "end_line": 4, + "filename": "", + "line": 4, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 18 } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "", - "line": 2, - "node": { - "ctx": "Load", - "names": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, + } + } + }, + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 17, + "end_line": 5, + "filename": "", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" + } + }, + "operation": "Union", + "value": { + "column": 19, + "end_column": 34, + "end_line": 5, + "filename": "", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" + } + } + } + }, + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 14, + "end_line": 3, "filename": "", - "line": 2, - "node": "list" + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 16, + "end_column": 23, + "end_line": 3, + "filename": "", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" + } } - ], - "pkgpath": "" + } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "", + "line": 2, + "node": { + "ctx": "Load", + "names": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "", + "line": 2, + "node": "list" } - } - }, - "type": "Schema" - } + ], + "pkgpath": "" + } + }, + "type": "Schema" } - ] - }, + } + ], "type": "List" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-5.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-5.snap index 4572c6acb..f63d815f3 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-5.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-5.snap @@ -9,465 +9,419 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 13, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, "filename": "", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" - } - } + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, "filename": "", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 5, - "filename": "", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"data\"", - "value": "data" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 12, - "end_column": 5, - "end_line": 8, - "filename": "", - "line": 5, - "node": { - "data": { - "items": [ - { - "column": 12, - "end_column": 5, - "end_line": 8, - "filename": "", - "line": 5, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 12, - "end_line": 6, - "filename": "", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"id\"", - "value": "id" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 15, - "end_line": 6, - "filename": "", - "line": 6, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" - } - } - } - }, - { - "column": 12, - "end_column": 5, - "end_line": 8, - "filename": "", - "line": 5, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 15, - "end_line": 7, - "filename": "", - "line": 7, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value\"", - "value": "value" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 17, - "end_column": 25, - "end_line": 7, - "filename": "", - "line": 7, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value1\"", - "value": "value1" - }, - "type": "StringLit" - } - } - } - } - ] - }, - "type": "Config" - } + "type": "Int", + "value": 18 } } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 5, + "filename": "", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"data\"", + "type": "StringLit", + "value": "data" + } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 12, + "end_column": 5, + "end_line": 8, "filename": "", - "line": 1, + "line": 5, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 8, - "end_line": 12, - "filename": "", - "line": 12, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"hc\"", - "value": "hc" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 10, - "end_column": 19, - "end_line": 12, - "filename": "", - "line": 12, - "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 11, - "end_column": 12, - "end_line": 12, - "filename": "", - "line": 12, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" - } - }, - { - "column": 14, - "end_column": 15, - "end_line": 12, - "filename": "", - "line": 12, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 2, - "type": "Int" - } - }, - "type": "NumberLit" - } - }, - { - "column": 17, - "end_column": 18, - "end_line": 12, - "filename": "", - "line": 12, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 3, - "type": "Int" - } - }, - "type": "NumberLit" + "items": [ + { + "column": 12, + "end_column": 5, + "end_line": 8, + "filename": "", + "line": 5, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 12, + "end_line": 6, + "filename": "", + "line": 6, + "node": { + "is_long_string": false, + "raw_value": "\"id\"", + "type": "StringLit", + "value": "id" + } + }, + "operation": "Union", + "value": { + "column": 14, + "end_column": 15, + "end_line": 6, + "filename": "", + "line": 6, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 } } - ] - }, - "type": "List" + } + } + }, + { + "column": 12, + "end_column": 5, + "end_line": 8, + "filename": "", + "line": 5, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 15, + "end_line": 7, + "filename": "", + "line": 7, + "node": { + "is_long_string": false, + "raw_value": "\"value\"", + "type": "StringLit", + "value": "value" + } + }, + "operation": "Union", + "value": { + "column": 17, + "end_column": 25, + "end_line": 7, + "filename": "", + "line": 7, + "node": { + "is_long_string": false, + "raw_value": "\"value1\"", + "type": "StringLit", + "value": "value1" + } + } + } } - } + ], + "type": "Config" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 8, + "end_line": 12, + "filename": "", + "line": 12, + "node": { + "is_long_string": false, + "raw_value": "\"hc\"", + "type": "StringLit", + "value": "hc" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 10, + "end_column": 19, + "end_line": 12, "filename": "", - "line": 1, + "line": 12, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 12, - "end_line": 9, - "filename": "", - "line": 9, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"labels\"", - "value": "labels" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "", - "line": 9, - "node": { - "data": { - "items": [ - { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "", - "line": 9, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 13, - "end_line": 10, - "filename": "", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"key\"", - "value": "key" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 22, - "end_line": 10, - "filename": "", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value\"", - "value": "value" - }, - "type": "StringLit" - } - } - } - } - ] - }, - "type": "Config" + "ctx": "Load", + "elts": [ + { + "column": 11, + "end_column": 12, + "end_line": 12, + "filename": "", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 + } + } + }, + { + "column": 14, + "end_column": 15, + "end_line": 12, + "filename": "", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 2 + } + } + }, + { + "column": 17, + "end_column": 18, + "end_line": 12, + "filename": "", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 3 + } + } } - } + ], + "type": "List" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 12, + "end_line": 9, + "filename": "", + "line": 9, + "node": { + "is_long_string": false, + "raw_value": "\"labels\"", + "type": "StringLit", + "value": "labels" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 14, + "end_column": 5, + "end_line": 11, "filename": "", - "line": 1, + "line": 9, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 30, - "end_line": 4, - "filename": "", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" + "items": [ + { + "column": 14, + "end_column": 5, + "end_line": 11, + "filename": "", + "line": 9, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 13, + "end_line": 10, + "filename": "", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"key\"", + "type": "StringLit", + "value": "key" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 22, + "end_line": 10, + "filename": "", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"value\"", + "type": "StringLit", + "value": "value" + } + } + } } - } + ], + "type": "Config" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, + "filename": "", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" } }, - { - "column": 0, - "end_column": 1, - "end_line": 13, + "operation": "Union", + "value": { + "column": 15, + "end_column": 30, + "end_line": 4, "filename": "", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 19, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" } } - ] + } }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "", - "line": 1, - "node": "complex" + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 19, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" + } + } } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "", + "line": 1, + "node": "complex" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-6.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-6.snap index 56b1ae6fd..3b8d839c6 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-6.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-6.snap @@ -9,82 +9,74 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 16, + "end_line": 2, "filename": "", - "line": 1, + "line": 2, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 16, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"null_value\"", - "value": "null_value" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 18, - "end_column": 22, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "value": "None" - }, - "type": "NameConstantLit" - } - } + "is_long_string": false, + "raw_value": "\"null_value\"", + "type": "StringLit", + "value": "null_value" + } + }, + "operation": "Union", + "value": { + "column": 18, + "end_column": 22, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "type": "NameConstantLit", + "value": "None" } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": "only_with_null" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": "only_with_null" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-7.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-7.snap index baecbf3c2..5d6e0bda7 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-7.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-7.snap @@ -9,82 +9,74 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, "filename": "", - "line": 1, + "line": 2, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"flag\"", - "value": "flag" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 16, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "value": "True" - }, - "type": "NameConstantLit" - } - } + "is_long_string": false, + "raw_value": "\"flag\"", + "type": "StringLit", + "value": "flag" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 16, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "type": "NameConstantLit", + "value": "True" } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": "only_with_bool" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": "only_with_bool" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-8.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-8.snap index 9608c19a4..5f14d9e73 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-8.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str-8.snap @@ -9,86 +9,78 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 17, + "end_line": 2, "filename": "", - "line": 1, + "line": 2, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 17, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"float_value\"", - "value": "float_value" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "is_long_string": false, + "raw_value": "\"float_value\"", + "type": "StringLit", + "value": "float_value" + } + }, + "operation": "Union", + "value": { + "column": 19, + "end_column": 23, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 19, - "end_column": 23, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 0.33, - "type": "Float" - } - }, - "type": "NumberLit" - } + "type": "Float", + "value": 0.33 } } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "", - "line": 1, - "node": "only_with_float" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "", + "line": 1, + "node": "only_with_float" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str.snap index 208e092cb..cebe71cae 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_json_with_str.snap @@ -9,320 +9,288 @@ expression: got_ast_json_str "filename": "", "line": 1, "node": { - "data": { - "args": [], - "config": { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "", - "line": 1, - "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 12, + "args": [], + "config": { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "", + "line": 1, + "node": { + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, "filename": "", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"address\"", - "value": "address" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 5, - "end_line": 7, - "filename": "", - "line": 4, - "node": { - "data": { - "items": [ - { - "column": 15, - "end_column": 5, - "end_line": 7, - "filename": "", - "line": 4, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 14, - "end_line": 6, - "filename": "", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"city\"", - "value": "city" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 16, - "end_column": 24, - "end_line": 6, - "filename": "", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"London\"", - "value": "London" - }, - "type": "StringLit" - } - } - } - }, - { - "column": 15, - "end_column": 5, - "end_line": 7, - "filename": "", - "line": 4, - "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 16, - "end_line": 5, - "filename": "", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"street\"", - "value": "street" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 18, - "end_column": 37, - "end_line": 5, - "filename": "", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"10 Downing Street\"", - "value": "10 Downing Street" - }, - "type": "StringLit" - } - } - } - } - ] - }, - "type": "Config" - } - } + "is_long_string": false, + "raw_value": "\"address\"", + "type": "StringLit", + "value": "address" } }, - { - "column": 0, - "end_column": 1, - "end_line": 12, + "operation": "Union", + "value": { + "column": 15, + "end_column": 5, + "end_line": 7, "filename": "", - "line": 1, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "", - "line": 3, - "node": { - "data": { - "binary_suffix": null, + "items": [ + { + "column": 15, + "end_column": 5, + "end_line": 7, + "filename": "", + "line": 4, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 14, + "end_line": 6, + "filename": "", + "line": 6, + "node": { + "is_long_string": false, + "raw_value": "\"city\"", + "type": "StringLit", + "value": "city" + } + }, + "operation": "Union", "value": { - "data": 43, - "type": "Int" + "column": 16, + "end_column": 24, + "end_line": 6, + "filename": "", + "line": 6, + "node": { + "is_long_string": false, + "raw_value": "\"London\"", + "type": "StringLit", + "value": "London" + } } - }, - "type": "NumberLit" + } + }, + { + "column": 15, + "end_column": 5, + "end_line": 7, + "filename": "", + "line": 4, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 16, + "end_line": 5, + "filename": "", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"street\"", + "type": "StringLit", + "value": "street" + } + }, + "operation": "Union", + "value": { + "column": 18, + "end_column": 37, + "end_line": 5, + "filename": "", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"10 Downing Street\"", + "type": "StringLit", + "value": "10 Downing Street" + } + } + } } - } + ], + "type": "Config" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, + "filename": "", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" } }, - { - "column": 0, - "end_column": 1, - "end_line": 12, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, "filename": "", - "line": 1, + "line": 3, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 12, - "end_column": 22, - "end_line": 2, - "filename": "", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"John Doe\"", - "value": "John Doe" - }, - "type": "StringLit" - } + "type": "Int", + "value": 43 } } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } }, - { - "column": 0, - "end_column": 1, - "end_line": 12, + "operation": "Union", + "value": { + "column": 12, + "end_column": 22, + "end_line": 2, + "filename": "", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"John Doe\"", + "type": "StringLit", + "value": "John Doe" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 12, + "end_line": 8, "filename": "", - "line": 1, + "line": 8, "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 12, - "end_line": 8, - "filename": "", - "line": 8, - "node": { - "data": { + "is_long_string": false, + "raw_value": "\"phones\"", + "type": "StringLit", + "value": "phones" + } + }, + "operation": "Union", + "value": { + "column": 14, + "end_column": 5, + "end_line": 11, + "filename": "", + "line": 8, + "node": { + "ctx": "Load", + "elts": [ + { + "column": 8, + "end_column": 21, + "end_line": 9, + "filename": "", + "line": 9, + "node": { "is_long_string": false, - "raw_value": "\"phones\"", - "value": "phones" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "", - "line": 8, - "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 8, - "end_column": 21, - "end_line": 9, - "filename": "", - "line": 9, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"+44 1234567\"", - "value": "+44 1234567" - }, - "type": "StringLit" - } - }, - { - "column": 8, - "end_column": 21, - "end_line": 10, - "filename": "", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"+44 2345678\"", - "value": "+44 2345678" - }, - "type": "StringLit" - } - } - ] - }, - "type": "List" + "raw_value": "\"+44 1234567\"", + "type": "StringLit", + "value": "+44 1234567" + } + }, + { + "column": 8, + "end_column": 21, + "end_line": 10, + "filename": "", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"+44 2345678\"", + "type": "StringLit", + "value": "+44 2345678" + } } - } + ], + "type": "List" } } - ] - }, - "type": "Config" - } - }, - "kwargs": [], - "name": { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "", - "line": 1, - "node": { - "ctx": "Load", - "names": [ - { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "", - "line": 1, - "node": "test" } - ], - "pkgpath": "" - } + } + ], + "type": "Config" + } + }, + "kwargs": [], + "name": { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "", + "line": 1, + "node": { + "ctx": "Load", + "names": [ + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "", + "line": 1, + "node": "test" + } + ], + "pkgpath": "" } }, "type": "Schema" diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-2.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-2.snap index c40cb2683..2cf71ad87 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-2.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-2.snap @@ -9,135 +9,121 @@ expression: got_ast_json_str "filename": "/simple.k.json", "line": 1, "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "/simple.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "/simple.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "/simple.k.json", - "line": 3, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, + "filename": "/simple.k.json", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" + } + }, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, + "filename": "/simple.k.json", + "line": 3, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 18 } } } - }, - { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "/simple.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "/simple.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 30, - "end_line": 4, - "filename": "/simple.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" - } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, + "filename": "/simple.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 30, + "end_line": 4, + "filename": "/simple.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" } } - }, - { - "column": 0, - "end_column": 1, - "end_line": 5, - "filename": "/simple.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/simple.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 19, - "end_line": 2, - "filename": "/simple.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 5, + "filename": "/simple.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "/simple.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 19, + "end_line": 2, + "filename": "/simple.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" } } } - ] - }, + } + ], "type": "Config" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-3.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-3.snap index c0a67c0ca..19165aa64 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-3.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-3.snap @@ -9,13 +9,11 @@ expression: got_ast_json_str "filename": "/plain_value.k.json", "line": 1, "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 + } } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-4.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-4.snap index 05e84deb1..22cb63f75 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-4.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-4.snap @@ -9,150 +9,134 @@ expression: got_ast_json_str "filename": "/list.k.json", "line": 1, "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, - "filename": "/list.k.json", - "line": 2, - "node": { - "data": { - "items": [ - { - "column": 4, - "end_column": 5, - "end_line": 6, + "ctx": "Load", + "elts": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "items": [ + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 13, + "end_line": 4, "filename": "/list.k.json", - "line": 2, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 13, - "end_line": 4, - "filename": "/list.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 17, - "end_line": 4, - "filename": "/list.k.json", - "line": 4, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" - } - } + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" } }, - { - "column": 4, - "end_column": 5, - "end_line": 6, + "operation": "Union", + "value": { + "column": 15, + "end_column": 17, + "end_line": 4, "filename": "/list.k.json", - "line": 2, + "line": 4, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 17, - "end_line": 5, - "filename": "/list.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 19, - "end_column": 34, - "end_line": 5, - "filename": "/list.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" - } + "type": "Int", + "value": 18 } } + } + } + }, + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 17, + "end_line": 5, + "filename": "/list.k.json", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" + } }, - { - "column": 4, - "end_column": 5, - "end_line": 6, + "operation": "Union", + "value": { + "column": 19, + "end_column": 34, + "end_line": 5, "filename": "/list.k.json", - "line": 2, + "line": 5, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 14, - "end_line": 3, - "filename": "/list.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 16, - "end_column": 23, - "end_line": 3, - "filename": "/list.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" } } - ] + } }, - "type": "Config" - } + { + "column": 4, + "end_column": 5, + "end_line": 6, + "filename": "/list.k.json", + "line": 2, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 14, + "end_line": 3, + "filename": "/list.k.json", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 16, + "end_column": 23, + "end_line": 3, + "filename": "/list.k.json", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" + } + } + } + } + ], + "type": "Config" } - ] - }, + } + ], "type": "List" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-5.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-5.snap index b91224bfb..389d673e8 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-5.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-5.snap @@ -9,432 +9,388 @@ expression: got_ast_json_str "filename": "/complex.k.json", "line": 1, "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "/complex.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "/complex.k.json", - "line": 3, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 18, - "type": "Int" - } - }, - "type": "NumberLit" + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, + "filename": "/complex.k.json", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" + } + }, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, + "filename": "/complex.k.json", + "line": 3, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 18 } } } - }, - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 5, - "filename": "/complex.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"data\"", - "value": "data" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 5, - "end_line": 8, - "filename": "/complex.k.json", - "line": 5, - "node": { - "data": { - "items": [ - { - "column": 12, - "end_column": 5, - "end_line": 8, + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 5, + "filename": "/complex.k.json", + "line": 5, + "node": { + "is_long_string": false, + "raw_value": "\"data\"", + "type": "StringLit", + "value": "data" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 5, + "end_line": 8, + "filename": "/complex.k.json", + "line": 5, + "node": { + "items": [ + { + "column": 12, + "end_column": 5, + "end_line": 8, + "filename": "/complex.k.json", + "line": 5, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 12, + "end_line": 6, "filename": "/complex.k.json", - "line": 5, + "line": 6, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 12, - "end_line": 6, - "filename": "/complex.k.json", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"id\"", - "value": "id" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 15, - "end_line": 6, - "filename": "/complex.k.json", - "line": 6, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" - } - } + "is_long_string": false, + "raw_value": "\"id\"", + "type": "StringLit", + "value": "id" } }, - { - "column": 12, - "end_column": 5, - "end_line": 8, + "operation": "Union", + "value": { + "column": 14, + "end_column": 15, + "end_line": 6, "filename": "/complex.k.json", - "line": 5, + "line": 6, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 15, - "end_line": 7, - "filename": "/complex.k.json", - "line": 7, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value\"", - "value": "value" - }, - "type": "StringLit" - } - }, - "operation": "Union", + "binary_suffix": null, + "type": "NumberLit", "value": { - "column": 17, - "end_column": 25, - "end_line": 7, - "filename": "/complex.k.json", - "line": 7, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value1\"", - "value": "value1" - }, - "type": "StringLit" - } + "type": "Int", + "value": 1 } } } - ] - }, - "type": "Config" - } - } - } - }, - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 8, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"hc\"", - "value": "hc" + } }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 10, - "end_column": 19, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "ctx": "Load", - "elts": [ - { - "column": 11, - "end_column": 12, - "end_line": 12, - "filename": "/complex.k.json", - "line": 12, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 1, - "type": "Int" - } - }, - "type": "NumberLit" - } - }, - { - "column": 14, + { + "column": 12, + "end_column": 5, + "end_line": 8, + "filename": "/complex.k.json", + "line": 5, + "node": { + "insert_index": -1, + "key": { + "column": 8, "end_column": 15, - "end_line": 12, + "end_line": 7, "filename": "/complex.k.json", - "line": 12, + "line": 7, "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 2, - "type": "Int" - } - }, - "type": "NumberLit" + "is_long_string": false, + "raw_value": "\"value\"", + "type": "StringLit", + "value": "value" } }, - { + "operation": "Union", + "value": { "column": 17, - "end_column": 18, - "end_line": 12, + "end_column": 25, + "end_line": 7, "filename": "/complex.k.json", - "line": 12, + "line": 7, "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 3, - "type": "Int" - } - }, - "type": "NumberLit" + "is_long_string": false, + "raw_value": "\"value1\"", + "type": "StringLit", + "value": "value1" } } - ] - }, - "type": "List" - } + } + } + ], + "type": "Config" } } - }, - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 12, - "end_line": 9, - "filename": "/complex.k.json", - "line": 9, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"labels\"", - "value": "labels" + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 8, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "is_long_string": false, + "raw_value": "\"hc\"", + "type": "StringLit", + "value": "hc" + } + }, + "operation": "Union", + "value": { + "column": 10, + "end_column": 19, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "ctx": "Load", + "elts": [ + { + "column": 11, + "end_column": 12, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 1 + } + } }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "/complex.k.json", - "line": 9, - "node": { - "data": { - "items": [ - { - "column": 14, - "end_column": 5, - "end_line": 11, + { + "column": 14, + "end_column": 15, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 2 + } + } + }, + { + "column": 17, + "end_column": 18, + "end_line": 12, + "filename": "/complex.k.json", + "line": 12, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 3 + } + } + } + ], + "type": "List" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 12, + "end_line": 9, + "filename": "/complex.k.json", + "line": 9, + "node": { + "is_long_string": false, + "raw_value": "\"labels\"", + "type": "StringLit", + "value": "labels" + } + }, + "operation": "Union", + "value": { + "column": 14, + "end_column": 5, + "end_line": 11, + "filename": "/complex.k.json", + "line": 9, + "node": { + "items": [ + { + "column": 14, + "end_column": 5, + "end_line": 11, + "filename": "/complex.k.json", + "line": 9, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 13, + "end_line": 10, "filename": "/complex.k.json", - "line": 9, + "line": 10, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 13, - "end_line": 10, - "filename": "/complex.k.json", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"key\"", - "value": "key" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 22, - "end_line": 10, - "filename": "/complex.k.json", - "line": 10, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"value\"", - "value": "value" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"key\"", + "type": "StringLit", + "value": "key" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 22, + "end_line": 10, + "filename": "/complex.k.json", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"value\"", + "type": "StringLit", + "value": "value" } } - ] - }, - "type": "Config" - } + } + } + ], + "type": "Config" } } - }, - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "/complex.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"message\"", - "value": "message" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 30, - "end_line": 4, - "filename": "/complex.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"This is Alice\"", - "value": "This is Alice" - }, - "type": "StringLit" - } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, + "filename": "/complex.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"message\"", + "type": "StringLit", + "value": "message" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 30, + "end_line": 4, + "filename": "/complex.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"This is Alice\"", + "type": "StringLit", + "value": "This is Alice" } } - }, - { - "column": 0, - "end_column": 1, - "end_line": 13, - "filename": "/complex.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/complex.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 19, - "end_line": 2, - "filename": "/complex.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"Alice\"", - "value": "Alice" - }, - "type": "StringLit" - } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 13, + "filename": "/complex.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "/complex.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 19, + "end_line": 2, + "filename": "/complex.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"Alice\"", + "type": "StringLit", + "value": "Alice" } } } - ] - }, + } + ], "type": "Config" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-6.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-6.snap index 0d1fe32ae..d3f3bb3dc 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-6.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-6.snap @@ -9,49 +9,43 @@ expression: got_ast_json_str "filename": "/only_with_null.json", "line": 1, "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_null.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 16, - "end_line": 2, - "filename": "/only_with_null.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"null_value\"", - "value": "null_value" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 18, - "end_column": 22, - "end_line": 2, - "filename": "/only_with_null.json", - "line": 2, - "node": { - "data": { - "value": "None" - }, - "type": "NameConstantLit" - } + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_null.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 16, + "end_line": 2, + "filename": "/only_with_null.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"null_value\"", + "type": "StringLit", + "value": "null_value" + } + }, + "operation": "Union", + "value": { + "column": 18, + "end_column": 22, + "end_line": 2, + "filename": "/only_with_null.json", + "line": 2, + "node": { + "type": "NameConstantLit", + "value": "None" } } } - ] - }, + } + ], "type": "Config" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-7.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-7.snap index 37b76912b..5ae411ae0 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-7.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-7.snap @@ -9,49 +9,43 @@ expression: got_ast_json_str "filename": "/only_with_bool.json", "line": 1, "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_bool.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/only_with_bool.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"flag\"", - "value": "flag" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 16, - "end_line": 2, - "filename": "/only_with_bool.json", - "line": 2, - "node": { - "data": { - "value": "True" - }, - "type": "NameConstantLit" - } + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_bool.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "/only_with_bool.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"flag\"", + "type": "StringLit", + "value": "flag" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 16, + "end_line": 2, + "filename": "/only_with_bool.json", + "line": 2, + "node": { + "type": "NameConstantLit", + "value": "True" } } } - ] - }, + } + ], "type": "Config" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-8.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-8.snap index bb103ea8f..2861cabd0 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-8.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name-8.snap @@ -9,53 +9,47 @@ expression: got_ast_json_str "filename": "/only_with_float.json", "line": 1, "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 3, - "filename": "/only_with_float.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 17, - "end_line": 2, - "filename": "/only_with_float.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"float_value\"", - "value": "float_value" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 19, - "end_column": 23, - "end_line": 2, - "filename": "/only_with_float.json", - "line": 2, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 0.33, - "type": "Float" - } - }, - "type": "NumberLit" + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 3, + "filename": "/only_with_float.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 17, + "end_line": 2, + "filename": "/only_with_float.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"float_value\"", + "type": "StringLit", + "value": "float_value" + } + }, + "operation": "Union", + "value": { + "column": 19, + "end_column": 23, + "end_line": 2, + "filename": "/only_with_float.json", + "line": 2, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Float", + "value": 0.33 } } } } - ] - }, + } + ], "type": "Config" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name.snap index 6f0d1edc3..686a9c5b8 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_json_no_schema_name.snap @@ -9,287 +9,257 @@ expression: got_ast_json_str "filename": "/test.k.json", "line": 1, "node": { - "data": { - "items": [ - { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "/test.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 13, - "end_line": 4, - "filename": "/test.k.json", - "line": 4, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"address\"", - "value": "address" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 15, - "end_column": 5, - "end_line": 7, - "filename": "/test.k.json", - "line": 4, - "node": { - "data": { - "items": [ - { - "column": 15, - "end_column": 5, - "end_line": 7, + "items": [ + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 13, + "end_line": 4, + "filename": "/test.k.json", + "line": 4, + "node": { + "is_long_string": false, + "raw_value": "\"address\"", + "type": "StringLit", + "value": "address" + } + }, + "operation": "Union", + "value": { + "column": 15, + "end_column": 5, + "end_line": 7, + "filename": "/test.k.json", + "line": 4, + "node": { + "items": [ + { + "column": 15, + "end_column": 5, + "end_line": 7, + "filename": "/test.k.json", + "line": 4, + "node": { + "insert_index": -1, + "key": { + "column": 8, + "end_column": 14, + "end_line": 6, "filename": "/test.k.json", - "line": 4, + "line": 6, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 14, - "end_line": 6, - "filename": "/test.k.json", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"city\"", - "value": "city" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 16, - "end_column": 24, - "end_line": 6, - "filename": "/test.k.json", - "line": 6, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"London\"", - "value": "London" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"city\"", + "type": "StringLit", + "value": "city" } }, - { - "column": 15, - "end_column": 5, - "end_line": 7, + "operation": "Union", + "value": { + "column": 16, + "end_column": 24, + "end_line": 6, "filename": "/test.k.json", - "line": 4, + "line": 6, "node": { - "insert_index": -1, - "key": { - "column": 8, - "end_column": 16, - "end_line": 5, - "filename": "/test.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"street\"", - "value": "street" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 18, - "end_column": 37, - "end_line": 5, - "filename": "/test.k.json", - "line": 5, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"10 Downing Street\"", - "value": "10 Downing Street" - }, - "type": "StringLit" - } - } + "is_long_string": false, + "raw_value": "\"London\"", + "type": "StringLit", + "value": "London" } } - ] - }, - "type": "Config" - } - } - } - }, - { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "/test.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 9, - "end_line": 3, - "filename": "/test.k.json", - "line": 3, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"age\"", - "value": "age" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 11, - "end_column": 13, - "end_line": 3, - "filename": "/test.k.json", - "line": 3, - "node": { - "data": { - "binary_suffix": null, - "value": { - "data": 43, - "type": "Int" } }, - "type": "NumberLit" - } - } - } - }, - { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "/test.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 10, - "end_line": 2, - "filename": "/test.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"name\"", - "value": "name" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 12, - "end_column": 22, - "end_line": 2, - "filename": "/test.k.json", - "line": 2, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"John Doe\"", - "value": "John Doe" - }, - "type": "StringLit" - } - } - } - }, - { - "column": 0, - "end_column": 1, - "end_line": 12, - "filename": "/test.k.json", - "line": 1, - "node": { - "insert_index": -1, - "key": { - "column": 4, - "end_column": 12, - "end_line": 8, - "filename": "/test.k.json", - "line": 8, - "node": { - "data": { - "is_long_string": false, - "raw_value": "\"phones\"", - "value": "phones" - }, - "type": "StringLit" - } - }, - "operation": "Union", - "value": { - "column": 14, - "end_column": 5, - "end_line": 11, - "filename": "/test.k.json", - "line": 8, - "node": { - "data": { - "ctx": "Load", - "elts": [ - { + { + "column": 15, + "end_column": 5, + "end_line": 7, + "filename": "/test.k.json", + "line": 4, + "node": { + "insert_index": -1, + "key": { "column": 8, - "end_column": 21, - "end_line": 9, + "end_column": 16, + "end_line": 5, "filename": "/test.k.json", - "line": 9, + "line": 5, "node": { - "data": { - "is_long_string": false, - "raw_value": "\"+44 1234567\"", - "value": "+44 1234567" - }, - "type": "StringLit" + "is_long_string": false, + "raw_value": "\"street\"", + "type": "StringLit", + "value": "street" } }, - { - "column": 8, - "end_column": 21, - "end_line": 10, + "operation": "Union", + "value": { + "column": 18, + "end_column": 37, + "end_line": 5, "filename": "/test.k.json", - "line": 10, + "line": 5, "node": { - "data": { - "is_long_string": false, - "raw_value": "\"+44 2345678\"", - "value": "+44 2345678" - }, - "type": "StringLit" + "is_long_string": false, + "raw_value": "\"10 Downing Street\"", + "type": "StringLit", + "value": "10 Downing Street" } } - ] - }, - "type": "List" + } + } + ], + "type": "Config" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 9, + "end_line": 3, + "filename": "/test.k.json", + "line": 3, + "node": { + "is_long_string": false, + "raw_value": "\"age\"", + "type": "StringLit", + "value": "age" + } + }, + "operation": "Union", + "value": { + "column": 11, + "end_column": 13, + "end_line": 3, + "filename": "/test.k.json", + "line": 3, + "node": { + "binary_suffix": null, + "type": "NumberLit", + "value": { + "type": "Int", + "value": 43 } } } } - ] - }, + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 10, + "end_line": 2, + "filename": "/test.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"name\"", + "type": "StringLit", + "value": "name" + } + }, + "operation": "Union", + "value": { + "column": 12, + "end_column": 22, + "end_line": 2, + "filename": "/test.k.json", + "line": 2, + "node": { + "is_long_string": false, + "raw_value": "\"John Doe\"", + "type": "StringLit", + "value": "John Doe" + } + } + } + }, + { + "column": 0, + "end_column": 1, + "end_line": 12, + "filename": "/test.k.json", + "line": 1, + "node": { + "insert_index": -1, + "key": { + "column": 4, + "end_column": 12, + "end_line": 8, + "filename": "/test.k.json", + "line": 8, + "node": { + "is_long_string": false, + "raw_value": "\"phones\"", + "type": "StringLit", + "value": "phones" + } + }, + "operation": "Union", + "value": { + "column": 14, + "end_column": 5, + "end_line": 11, + "filename": "/test.k.json", + "line": 8, + "node": { + "ctx": "Load", + "elts": [ + { + "column": 8, + "end_column": 21, + "end_line": 9, + "filename": "/test.k.json", + "line": 9, + "node": { + "is_long_string": false, + "raw_value": "\"+44 1234567\"", + "type": "StringLit", + "value": "+44 1234567" + } + }, + { + "column": 8, + "end_column": 21, + "end_line": 10, + "filename": "/test.k.json", + "line": 10, + "node": { + "is_long_string": false, + "raw_value": "\"+44 2345678\"", + "type": "StringLit", + "value": "+44 2345678" + } + } + ], + "type": "List" + } + } + } + } + ], "type": "Config" } } diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-2.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-2.snap index 41af3f7fc..884b88940 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-2.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-2.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"name\"","value":"name"}},"filename":"/simple.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Alice,\"","value":"Alice,"}},"filename":"/simple.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"age\"","value":"age"}},"filename":"/simple.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"18,\"","value":"18,"}},"filename":"/simple.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"message\"","value":"message"}},"filename":"/simple.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"}},"filename":"/simple.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]}},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} +{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"name\"","value":"name"},"filename":"/simple.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Alice,\"","value":"Alice,"},"filename":"/simple.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"age\"","value":"age"},"filename":"/simple.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"18,\"","value":"18,"},"filename":"/simple.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"message\"","value":"message"},"filename":"/simple.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"},"filename":"/simple.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-3.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-3.snap index 65c907127..0a462296b 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-3.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-3.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":1}}},"filename":"/plain_value.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} +{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":1}},"filename":"/plain_value.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-4.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-4.snap index ad1351be4..4abc726e5 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-4.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-4.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"List","data":{"elts":[{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"name\"","value":"name"}},"filename":"/list.k.yaml","line":1,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"}},"filename":"/list.k.yaml","line":1,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"age\"","value":"age"}},"filename":"/list.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":18}}},"filename":"/list.k.yaml","line":2,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"message\"","value":"message"}},"filename":"/list.k.yaml","line":3,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"}},"filename":"/list.k.yaml","line":3,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}]}},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"}},"filename":"/list.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} +{"node":{"type":"List","elts":[{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"name\"","value":"name"},"filename":"/list.k.yaml","line":1,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"},"filename":"/list.k.yaml","line":1,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"age\"","value":"age"},"filename":"/list.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":18}},"filename":"/list.k.yaml","line":2,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"message\"","value":"message"},"filename":"/list.k.yaml","line":3,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"},"filename":"/list.k.yaml","line":3,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}]},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"},"filename":"/list.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-5.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-5.snap index 44d5e9ca1..8828b7ea7 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-5.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-5.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"name\"","value":"name"}},"filename":"/complex.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"}},"filename":"/complex.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"age\"","value":"age"}},"filename":"/complex.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":18}}},"filename":"/complex.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"message\"","value":"message"}},"filename":"/complex.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"}},"filename":"/complex.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"data\"","value":"data"}},"filename":"/complex.k.yaml","line":4,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"id\"","value":"id"}},"filename":"/complex.k.yaml","line":5,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":1}}},"filename":"/complex.k.yaml","line":5,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"value\"","value":"value"}},"filename":"/complex.k.yaml","line":6,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"value1\"","value":"value1"}},"filename":"/complex.k.yaml","line":6,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0}]}},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"labels\"","value":"labels"}},"filename":"/complex.k.yaml","line":7,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"key\"","value":"key"}},"filename":"/complex.k.yaml","line":8,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"value\"","value":"value"}},"filename":"/complex.k.yaml","line":8,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0}]}},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"hc\"","value":"hc"}},"filename":"/complex.k.yaml","line":9,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","data":{"elts":[{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":1}}},"filename":"/complex.k.yaml","line":10,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":2}}},"filename":"/complex.k.yaml","line":11,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":3}}},"filename":"/complex.k.yaml","line":12,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"}},"filename":"/complex.k.yaml","line":10,"column":4,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]}},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} +{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"name\"","value":"name"},"filename":"/complex.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"},"filename":"/complex.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"age\"","value":"age"},"filename":"/complex.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":18}},"filename":"/complex.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"message\"","value":"message"},"filename":"/complex.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"},"filename":"/complex.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"data\"","value":"data"},"filename":"/complex.k.yaml","line":4,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"id\"","value":"id"},"filename":"/complex.k.yaml","line":5,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":1}},"filename":"/complex.k.yaml","line":5,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"value\"","value":"value"},"filename":"/complex.k.yaml","line":6,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"value1\"","value":"value1"},"filename":"/complex.k.yaml","line":6,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0}]},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"labels\"","value":"labels"},"filename":"/complex.k.yaml","line":7,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"key\"","value":"key"},"filename":"/complex.k.yaml","line":8,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"value\"","value":"value"},"filename":"/complex.k.yaml","line":8,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0}]},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"hc\"","value":"hc"},"filename":"/complex.k.yaml","line":9,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","elts":[{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":1}},"filename":"/complex.k.yaml","line":10,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":2}},"filename":"/complex.k.yaml","line":11,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":3}},"filename":"/complex.k.yaml","line":12,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"},"filename":"/complex.k.yaml","line":10,"column":4,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-6.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-6.snap index 27d9f4d0c..a56aff609 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-6.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-6.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"null_val\"","value":"null_val"}},"filename":"/only_with_null.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","data":{"value":"None"}},"filename":"/only_with_null.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}]}},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0} +{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"null_val\"","value":"null_val"},"filename":"/only_with_null.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","value":"None"},"filename":"/only_with_null.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}]},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-7.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-7.snap index a65c61974..048edc552 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-7.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-7.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"bool_val\"","value":"bool_val"}},"filename":"/only_with_bool.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","data":{"value":"True"}},"filename":"/only_with_bool.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}]}},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0} +{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"bool_val\"","value":"bool_val"},"filename":"/only_with_bool.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","value":"True"},"filename":"/only_with_bool.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}]},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-8.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-8.snap index 17bbcb643..cbde2526e 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-8.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name-8.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"float_val\"","value":"float_val"}},"filename":"/only_with_float.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Float","data":0.33}}},"filename":"/only_with_float.yaml","line":1,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}]}},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0} +{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"float_val\"","value":"float_val"},"filename":"/only_with_float.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Float","value":0.33}},"filename":"/only_with_float.yaml","line":1,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}]},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name.snap index 395e11230..bc42c7584 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_with_yaml_no_schema_name.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"languages\"","value":"languages"}},"filename":"/test.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","data":{"elts":[{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"}},"filename":"/test.k.yaml","line":2,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"}},"filename":"/test.k.yaml","line":3,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Python\"","value":"Python"}},"filename":"/test.k.yaml","line":4,"column":4,"end_line":0,"end_column":0}],"ctx":"Load"}},"filename":"/test.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"websites\"","value":"websites"}},"filename":"/test.k.yaml","line":5,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"YAML\"","value":"YAML"}},"filename":"/test.k.yaml","line":6,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"yaml.org\"","value":"yaml.org"}},"filename":"/test.k.yaml","line":6,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"}},"filename":"/test.k.yaml","line":7,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"ruby-lang.org\"","value":"ruby-lang.org"}},"filename":"/test.k.yaml","line":7,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Python\"","value":"Python"}},"filename":"/test.k.yaml","line":8,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"python.org\"","value":"python.org"}},"filename":"/test.k.yaml","line":8,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"}},"filename":"/test.k.yaml","line":9,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"use.perl.org\"","value":"use.perl.org"}},"filename":"/test.k.yaml","line":9,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0}]}},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}]}},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0} +{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"languages\"","value":"languages"},"filename":"/test.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","elts":[{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"},"filename":"/test.k.yaml","line":2,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"},"filename":"/test.k.yaml","line":3,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Python\"","value":"Python"},"filename":"/test.k.yaml","line":4,"column":4,"end_line":0,"end_column":0}],"ctx":"Load"},"filename":"/test.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"websites\"","value":"websites"},"filename":"/test.k.yaml","line":5,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"YAML\"","value":"YAML"},"filename":"/test.k.yaml","line":6,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"yaml.org\"","value":"yaml.org"},"filename":"/test.k.yaml","line":6,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"},"filename":"/test.k.yaml","line":7,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"ruby-lang.org\"","value":"ruby-lang.org"},"filename":"/test.k.yaml","line":7,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Python\"","value":"Python"},"filename":"/test.k.yaml","line":8,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"python.org\"","value":"python.org"},"filename":"/test.k.yaml","line":8,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"},"filename":"/test.k.yaml","line":9,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"use.perl.org\"","value":"use.perl.org"},"filename":"/test.k.yaml","line":9,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0}]},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}]},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-2.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-2.snap index be6964963..ef00d15f9 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-2.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-2.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Schema","data":{"name":{"node":{"names":[{"node":"simple","filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"name\"","value":"name"}},"filename":"/simple.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Alice,\"","value":"Alice,"}},"filename":"/simple.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"age\"","value":"age"}},"filename":"/simple.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"18,\"","value":"18,"}},"filename":"/simple.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"message\"","value":"message"}},"filename":"/simple.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"}},"filename":"/simple.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]}},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}}},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} +{"node":{"type":"Schema","name":{"node":{"names":[{"node":"simple","filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"name\"","value":"name"},"filename":"/simple.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Alice,\"","value":"Alice,"},"filename":"/simple.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"age\"","value":"age"},"filename":"/simple.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"18,\"","value":"18,"},"filename":"/simple.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"message\"","value":"message"},"filename":"/simple.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"},"filename":"/simple.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}},"filename":"/simple.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-3.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-3.snap index 65c907127..0a462296b 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-3.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-3.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":1}}},"filename":"/plain_value.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} +{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":1}},"filename":"/plain_value.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-4.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-4.snap index 607f56814..7cbe04455 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-4.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-4.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"List","data":{"elts":[{"node":{"type":"Schema","data":{"name":{"node":{"names":[{"node":"list","filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"name\"","value":"name"}},"filename":"/list.k.yaml","line":1,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"}},"filename":"/list.k.yaml","line":1,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"age\"","value":"age"}},"filename":"/list.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":18}}},"filename":"/list.k.yaml","line":2,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"message\"","value":"message"}},"filename":"/list.k.yaml","line":3,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"}},"filename":"/list.k.yaml","line":3,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}]}},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}}},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"}},"filename":"/list.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} +{"node":{"type":"List","elts":[{"node":{"type":"Schema","name":{"node":{"names":[{"node":"list","filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"name\"","value":"name"},"filename":"/list.k.yaml","line":1,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"},"filename":"/list.k.yaml","line":1,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"age\"","value":"age"},"filename":"/list.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":18}},"filename":"/list.k.yaml","line":2,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"message\"","value":"message"},"filename":"/list.k.yaml","line":3,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"},"filename":"/list.k.yaml","line":3,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}]},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}},"filename":"/list.k.yaml","line":1,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"},"filename":"/list.k.yaml","line":1,"column":0,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-5.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-5.snap index c286526da..29c6875fa 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-5.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-5.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Schema","data":{"name":{"node":{"names":[{"node":"complex","filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"name\"","value":"name"}},"filename":"/complex.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"}},"filename":"/complex.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"age\"","value":"age"}},"filename":"/complex.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":18}}},"filename":"/complex.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"message\"","value":"message"}},"filename":"/complex.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"}},"filename":"/complex.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"data\"","value":"data"}},"filename":"/complex.k.yaml","line":4,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"id\"","value":"id"}},"filename":"/complex.k.yaml","line":5,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":1}}},"filename":"/complex.k.yaml","line":5,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"value\"","value":"value"}},"filename":"/complex.k.yaml","line":6,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"value1\"","value":"value1"}},"filename":"/complex.k.yaml","line":6,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0}]}},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"labels\"","value":"labels"}},"filename":"/complex.k.yaml","line":7,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"key\"","value":"key"}},"filename":"/complex.k.yaml","line":8,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"value\"","value":"value"}},"filename":"/complex.k.yaml","line":8,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0}]}},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"hc\"","value":"hc"}},"filename":"/complex.k.yaml","line":9,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","data":{"elts":[{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":1}}},"filename":"/complex.k.yaml","line":10,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":2}}},"filename":"/complex.k.yaml","line":11,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Int","data":3}}},"filename":"/complex.k.yaml","line":12,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"}},"filename":"/complex.k.yaml","line":10,"column":4,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]}},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}}},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} +{"node":{"type":"Schema","name":{"node":{"names":[{"node":"complex","filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"name\"","value":"name"},"filename":"/complex.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Alice\"","value":"Alice"},"filename":"/complex.k.yaml","line":1,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"age\"","value":"age"},"filename":"/complex.k.yaml","line":2,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":18}},"filename":"/complex.k.yaml","line":2,"column":5,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"message\"","value":"message"},"filename":"/complex.k.yaml","line":3,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"This is Alice\"","value":"This is Alice"},"filename":"/complex.k.yaml","line":3,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"data\"","value":"data"},"filename":"/complex.k.yaml","line":4,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"id\"","value":"id"},"filename":"/complex.k.yaml","line":5,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":1}},"filename":"/complex.k.yaml","line":5,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"value\"","value":"value"},"filename":"/complex.k.yaml","line":6,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"value1\"","value":"value1"},"filename":"/complex.k.yaml","line":6,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0}]},"filename":"/complex.k.yaml","line":5,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"labels\"","value":"labels"},"filename":"/complex.k.yaml","line":7,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"key\"","value":"key"},"filename":"/complex.k.yaml","line":8,"column":4,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"value\"","value":"value"},"filename":"/complex.k.yaml","line":8,"column":9,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0}]},"filename":"/complex.k.yaml","line":8,"column":7,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"hc\"","value":"hc"},"filename":"/complex.k.yaml","line":9,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","elts":[{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":1}},"filename":"/complex.k.yaml","line":10,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":2}},"filename":"/complex.k.yaml","line":11,"column":6,"end_line":0,"end_column":0},{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Int","value":3}},"filename":"/complex.k.yaml","line":12,"column":6,"end_line":0,"end_column":0}],"ctx":"Load"},"filename":"/complex.k.yaml","line":10,"column":4,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}]},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0}},"filename":"/complex.k.yaml","line":1,"column":4,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-6.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-6.snap index 9613f3c57..251847505 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-6.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-6.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Schema","data":{"name":{"node":{"names":[{"node":"only_with_null","filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"null_val\"","value":"null_val"}},"filename":"/only_with_null.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","data":{"value":"None"}},"filename":"/only_with_null.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}]}},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}}},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0} +{"node":{"type":"Schema","name":{"node":{"names":[{"node":"only_with_null","filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"null_val\"","value":"null_val"},"filename":"/only_with_null.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","value":"None"},"filename":"/only_with_null.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}]},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0}},"filename":"/only_with_null.yaml","line":1,"column":8,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-7.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-7.snap index 72bb7fd6b..baed11e7c 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-7.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-7.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Schema","data":{"name":{"node":{"names":[{"node":"only_with_bool","filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"bool_val\"","value":"bool_val"}},"filename":"/only_with_bool.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","data":{"value":"True"}},"filename":"/only_with_bool.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}]}},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}}},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0} +{"node":{"type":"Schema","name":{"node":{"names":[{"node":"only_with_bool","filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"bool_val\"","value":"bool_val"},"filename":"/only_with_bool.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NameConstantLit","value":"True"},"filename":"/only_with_bool.yaml","line":1,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}]},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0}},"filename":"/only_with_bool.yaml","line":1,"column":8,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-8.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-8.snap index 3b9cef936..cf92614c0 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-8.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml-8.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Schema","data":{"name":{"node":{"names":[{"node":"only_with_float","filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"float_val\"","value":"float_val"}},"filename":"/only_with_float.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","data":{"binary_suffix":null,"value":{"type":"Float","data":0.33}}},"filename":"/only_with_float.yaml","line":1,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}]}},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}}},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0} +{"node":{"type":"Schema","name":{"node":{"names":[{"node":"only_with_float","filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"float_val\"","value":"float_val"},"filename":"/only_with_float.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"NumberLit","binary_suffix":null,"value":{"type":"Float","value":0.33}},"filename":"/only_with_float.yaml","line":1,"column":11,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}]},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0}},"filename":"/only_with_float.yaml","line":1,"column":9,"end_line":0,"end_column":0} diff --git a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml.snap b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml.snap index a7f6b8700..41dea12dd 100644 --- a/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml.snap +++ b/kclvm/tools/src/vet/snapshots/kclvm_tools__vet__tests__test_expr_builder__build_yaml.snap @@ -2,4 +2,4 @@ source: tools/src/vet/tests.rs expression: got_ast_yaml_str --- -{"node":{"type":"Schema","data":{"name":{"node":{"names":[{"node":"test","filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"languages\"","value":"languages"}},"filename":"/test.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","data":{"elts":[{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"}},"filename":"/test.k.yaml","line":2,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"}},"filename":"/test.k.yaml","line":3,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Python\"","value":"Python"}},"filename":"/test.k.yaml","line":4,"column":4,"end_line":0,"end_column":0}],"ctx":"Load"}},"filename":"/test.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"websites\"","value":"websites"}},"filename":"/test.k.yaml","line":5,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","data":{"items":[{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"YAML\"","value":"YAML"}},"filename":"/test.k.yaml","line":6,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"yaml.org\"","value":"yaml.org"}},"filename":"/test.k.yaml","line":6,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"}},"filename":"/test.k.yaml","line":7,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"ruby-lang.org\"","value":"ruby-lang.org"}},"filename":"/test.k.yaml","line":7,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Python\"","value":"Python"}},"filename":"/test.k.yaml","line":8,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"python.org\"","value":"python.org"}},"filename":"/test.k.yaml","line":8,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"}},"filename":"/test.k.yaml","line":9,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","data":{"is_long_string":false,"raw_value":"\"use.perl.org\"","value":"use.perl.org"}},"filename":"/test.k.yaml","line":9,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0}]}},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}]}},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}}},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0} +{"node":{"type":"Schema","name":{"node":{"names":[{"node":"test","filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}],"pkgpath":"","ctx":"Load"},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0},"args":[],"kwargs":[],"config":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"languages\"","value":"languages"},"filename":"/test.k.yaml","line":1,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"List","elts":[{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"},"filename":"/test.k.yaml","line":2,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"},"filename":"/test.k.yaml","line":3,"column":4,"end_line":0,"end_column":0},{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Python\"","value":"Python"},"filename":"/test.k.yaml","line":4,"column":4,"end_line":0,"end_column":0}],"ctx":"Load"},"filename":"/test.k.yaml","line":2,"column":2,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"websites\"","value":"websites"},"filename":"/test.k.yaml","line":5,"column":0,"end_line":0,"end_column":0},"value":{"node":{"type":"Config","items":[{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"YAML\"","value":"YAML"},"filename":"/test.k.yaml","line":6,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"yaml.org\"","value":"yaml.org"},"filename":"/test.k.yaml","line":6,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Ruby\"","value":"Ruby"},"filename":"/test.k.yaml","line":7,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"ruby-lang.org\"","value":"ruby-lang.org"},"filename":"/test.k.yaml","line":7,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Python\"","value":"Python"},"filename":"/test.k.yaml","line":8,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"python.org\"","value":"python.org"},"filename":"/test.k.yaml","line":8,"column":10,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},{"node":{"key":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"Perl\"","value":"Perl"},"filename":"/test.k.yaml","line":9,"column":2,"end_line":0,"end_column":0},"value":{"node":{"type":"StringLit","is_long_string":false,"raw_value":"\"use.perl.org\"","value":"use.perl.org"},"filename":"/test.k.yaml","line":9,"column":8,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0}]},"filename":"/test.k.yaml","line":6,"column":6,"end_line":0,"end_column":0},"operation":"Union","insert_index":-1},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}]},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}},"filename":"/test.k.yaml","line":1,"column":9,"end_line":0,"end_column":0}