From f298b9897c2913f00009d66cd8673b086bd19be8 Mon Sep 17 00:00:00 2001 From: peefy Date: Thu, 4 Jan 2024 13:50:22 +0800 Subject: [PATCH] refactor: simplify AST type definition and make type erasure pass more stable Signed-off-by: peefy --- kclvm/ast/src/ast.rs | 26 ++++---- kclvm/ast_pretty/src/node.rs | 24 ++++---- kclvm/compiler/src/codegen/llvm/node.rs | 15 +++-- kclvm/parser/src/parser/expr.rs | 3 - kclvm/parser/src/parser/stmt.rs | 61 +++++-------------- ...kclvm_parser__tests__ast__assign_stmt.snap | 3 +- .../kclvm_parser__tests__ast__basic_stmt.snap | 3 +- .../kclvm_parser__tests__ast__if_stmt_0.snap | 3 +- .../kclvm_parser__tests__ast__if_stmt_1.snap | 3 +- ...kclvm_parser__tests__ast__schema_stmt.snap | 3 +- ...rror_recovery__assign_stmt_recovery_0.snap | 2 +- ...rror_recovery__assign_stmt_recovery_2.snap | 11 +--- ...rror_recovery__assign_stmt_recovery_3.snap | 11 +--- ...rror_recovery__assign_stmt_recovery_4.snap | 11 +--- ...rror_recovery__assign_stmt_recovery_5.snap | 2 +- ...rror_recovery__assign_stmt_recovery_6.snap | 2 +- ...rror_recovery__assign_stmt_recovery_7.snap | 11 +--- ...rror_recovery__assign_stmt_recovery_8.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_0.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_1.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_10.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_11.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_12.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_13.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_14.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_15.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_16.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_17.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_18.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_19.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_2.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_20.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_21.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_22.snap | 11 +--- ...ecovery__fn_ty_annotation_recovery_23.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_3.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_4.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_5.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_6.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_7.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_8.snap | 11 +--- ...recovery__fn_ty_annotation_recovery_9.snap | 11 +--- ...s__error_recovery__if_stmt_recovery_0.snap | 2 +- ...s__error_recovery__if_stmt_recovery_1.snap | 3 +- ...s__error_recovery__if_stmt_recovery_2.snap | 2 +- ...s__error_recovery__if_stmt_recovery_3.snap | 3 +- ...s__error_recovery__if_stmt_recovery_4.snap | 11 +--- ...ts__error_recovery__lambda_recovery_0.snap | 4 +- ...ts__error_recovery__lambda_recovery_1.snap | 3 +- ...ts__error_recovery__lambda_recovery_2.snap | 3 +- ...ts__error_recovery__lambda_recovery_3.snap | 6 +- ...ts__error_recovery__lambda_recovery_4.snap | 3 +- ...ts__error_recovery__lambda_recovery_5.snap | 6 +- ..._error_recovery__rule_stmt_recovery_2.snap | 2 +- ...ror_recovery__schema_stmt_recovery_10.snap | 11 +--- ...ror_recovery__schema_stmt_recovery_11.snap | 11 +--- ...ror_recovery__schema_stmt_recovery_12.snap | 11 +--- ...ror_recovery__schema_stmt_recovery_13.snap | 11 +--- ...ror_recovery__schema_stmt_recovery_17.snap | 11 +--- ...ror_recovery__schema_stmt_recovery_19.snap | 9 +-- ...rror_recovery__schema_stmt_recovery_2.snap | 2 +- ...ror_recovery__schema_stmt_recovery_20.snap | 9 +-- ...ror_recovery__schema_stmt_recovery_21.snap | 9 +-- ...ror_recovery__schema_stmt_recovery_22.snap | 9 +-- ...ror_recovery__schema_stmt_recovery_23.snap | 9 +-- ...ror_recovery__schema_stmt_recovery_24.snap | 9 +-- ...ror_recovery__schema_stmt_recovery_29.snap | 9 +-- ...ror_recovery__schema_stmt_recovery_31.snap | 32 ++++++---- ...ror_recovery__schema_stmt_recovery_32.snap | 8 --- ...ror_recovery__schema_stmt_recovery_33.snap | 8 --- ...ror_recovery__schema_stmt_recovery_35.snap | 8 --- ...rror_recovery__schema_stmt_recovery_7.snap | 11 +--- ...rror_recovery__schema_stmt_recovery_8.snap | 11 +--- ...rror_recovery__schema_stmt_recovery_9.snap | 11 +--- ...vm_parser__tests__expr__lambda_expr_0.snap | 2 +- ...vm_parser__tests__expr__lambda_expr_1.snap | 5 +- ...vm_parser__tests__expr__lambda_expr_2.snap | 16 +---- ...vm_parser__tests__expr__lambda_expr_3.snap | 4 +- .../kclvm_parser__tests__file__assert_2.snap | 3 +- .../kclvm_parser__tests__file__assert_3.snap | 3 +- ...clvm_parser__tests__file__assert_if_0.snap | 3 +- ...clvm_parser__tests__file__assert_if_1.snap | 3 +- ...clvm_parser__tests__file__assert_if_2.snap | 3 +- .../kclvm_parser__tests__file__assign_1.snap | 3 +- ...vm_parser__tests__file__config_expr_1.snap | 3 +- ...vm_parser__tests__file__config_expr_2.snap | 3 +- ...vm_parser__tests__file__config_expr_3.snap | 3 +- ...vm_parser__tests__file__config_expr_4.snap | 3 +- .../kclvm_parser__tests__file__hello_win.snap | 3 +- .../kclvm_parser__tests__file__if_1.snap | 3 +- .../kclvm_parser__tests__file__if_2.snap | 3 +- .../kclvm_parser__tests__file__if_3.snap | 3 +- kclvm/sema/src/resolver/global.rs | 6 +- kclvm/sema/src/resolver/mod.rs | 19 +++--- kclvm/sema/src/resolver/node.rs | 7 +-- kclvm/sema/src/resolver/tests.rs | 4 +- kclvm/sema/src/resolver/ty.rs | 2 +- kclvm/sema/src/resolver/ty_alias.rs | 38 +++++++----- .../{type_erasure.rs => ty_erasure.rs} | 25 +++----- kclvm/tools/src/LSP/src/rename.rs | 2 +- kclvm/tools/src/LSP/src/util.rs | 13 +++- kclvm/tools/src/vet/validator.rs | 1 - 102 files changed, 232 insertions(+), 680 deletions(-) rename kclvm/sema/src/resolver/{type_erasure.rs => ty_erasure.rs} (69%) diff --git a/kclvm/ast/src/ast.rs b/kclvm/ast/src/ast.rs index 28b3b2f9c..e0059fd5b 100644 --- a/kclvm/ast/src/ast.rs +++ b/kclvm/ast/src/ast.rs @@ -31,9 +31,7 @@ //! :note: When the definition of any AST node is modified or the AST node //! is added/deleted, it is necessary to modify the corresponding processing //! in the compiler and regenerate the walker code. -//! :copyright: Copyright 2020 The KCL Authors. All rights reserved. -//! -//! todo: remove type_str fields after python frontend removed. +//! :copyright: Copyright The KCL Authors. All rights reserved. use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -435,8 +433,6 @@ pub struct UnificationStmt { pub struct AssignStmt { pub targets: Vec>, pub value: NodeRef, - pub type_annotation: Option>, - pub ty: Option>, } @@ -608,11 +604,9 @@ impl SchemaStmt { #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct SchemaIndexSignature { pub key_name: Option, - pub key_type: NodeRef, - pub value_type: NodeRef, pub value: Option>, pub any_other: bool, - + pub key_ty: NodeRef, pub value_ty: NodeRef, } @@ -626,7 +620,6 @@ pub struct SchemaIndexSignature { pub struct SchemaAttr { pub doc: String, pub name: NodeRef, - pub type_str: NodeRef, pub op: Option, pub value: Option>, pub is_optional: bool, @@ -996,9 +989,7 @@ pub struct CheckExpr { #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct LambdaExpr { pub args: Option>, - pub return_type_str: Option, pub body: Vec>, - pub return_ty: Option>, } @@ -1039,9 +1030,6 @@ pub struct Keyword { pub struct Arguments { pub args: Vec>, pub defaults: Vec>>, - pub type_annotation_list: Vec>>, - - #[serde(default)] pub ty_list: Vec>>, } @@ -1684,6 +1672,16 @@ impl ToString for Type { } } +impl From for Type { + fn from(value: String) -> Self { + Type::Named(Identifier { + names: vec![Node::dummy_node(value)], + pkgpath: "".to_string(), + ctx: ExprContext::Load, + }) + } +} + impl From for AugOp { fn from(op_kind: token::BinOpToken) -> Self { match op_kind { diff --git a/kclvm/ast_pretty/src/node.rs b/kclvm/ast_pretty/src/node.rs index 87077edad..23604fc2d 100644 --- a/kclvm/ast_pretty/src/node.rs +++ b/kclvm/ast_pretty/src/node.rs @@ -10,10 +10,7 @@ use kclvm_ast::{ use super::{Indentation, Printer}; type ParameterType<'a> = ( - ( - &'a ast::NodeRef, - &'a Option>, - ), + (&'a ast::NodeRef, Option), &'a Option>, ); @@ -224,11 +221,11 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { if let Some(key_name) = &index_signature.node.key_name { self.write(&format!("{}: ", key_name)); } - self.write(&index_signature.node.key_type.node); + self.write(&index_signature.node.key_ty.node.to_string()); self.write_token(TokenKind::CloseDelim(DelimToken::Bracket)); self.write_token(TokenKind::Colon); self.write_space(); - self.write(&index_signature.node.value_type.node); + self.write(&index_signature.node.value_ty.node.to_string()); if let Some(value) = &index_signature.node.value { self.write(" = "); self.expr(value); @@ -350,7 +347,7 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { self.write("?"); } self.write(": "); - self.write(&schema_attr.type_str.node); + 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(), @@ -671,11 +668,11 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { self.write_space(); self.walk_arguments(&args.node); } - if let Some(ty_str) = &lambda_expr.return_type_str { + if let Some(ty_str) = &lambda_expr.return_ty { self.write_space(); self.write_token(TokenKind::RArrow); self.write_space(); - self.write(ty_str); + self.write(&ty_str.node.to_string()); } self.write_space(); self.write_token(TokenKind::OpenDelim(DelimToken::Brace)); @@ -702,7 +699,12 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { let parameter_zip_list: Vec> = arguments .args .iter() - .zip(arguments.type_annotation_list.iter()) + .zip( + arguments + .ty_list + .iter() + .map(|ty| ty.clone().map(|n| n.node.to_string())), + ) .zip(arguments.defaults.iter()) .collect(); interleave!( @@ -711,7 +713,7 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { let ((arg, ty_str), default) = para; self.walk_identifier(&arg.node); if let Some(ty_str) = ty_str { - self.write(&format!(": {}", ty_str.node)); + self.write(&format!(": {}", ty_str)); } if let Some(default) = default { self.write(" = "); diff --git a/kclvm/compiler/src/codegen/llvm/node.rs b/kclvm/compiler/src/codegen/llvm/node.rs index 1f223aa9c..3d4ac8375 100644 --- a/kclvm/compiler/src/codegen/llvm/node.rs +++ b/kclvm/compiler/src/codegen/llvm/node.rs @@ -161,8 +161,8 @@ impl<'ctx> TypedResultWalker<'ctx> for LLVMCodeGenContext<'ctx> { let mut value = self .walk_expr(&assign_stmt.value) .expect(kcl_error::COMPILE_ERROR_MSG); - if let Some(type_annotation) = &assign_stmt.type_annotation { - let type_annotation = self.native_global_string_value(&type_annotation.node); + if let Some(ty) = &assign_stmt.ty { + let type_annotation = self.native_global_string_value(&ty.node.to_string()); let is_in_schema = self.schema_stack.borrow().len() > 0 || self.schema_expr_stack.borrow().len() > 0; value = self.build_call( @@ -780,10 +780,13 @@ impl<'ctx> TypedResultWalker<'ctx> for LLVMCodeGenContext<'ctx> { schema_name_native_str, index_sign_value, key_name_str_ptr.into(), - self.native_global_string(index_signature.node.key_type.node.as_str(), "") - .into(), self.native_global_string( - index_signature.node.value_type.node.as_str(), + index_signature.node.key_ty.node.to_string().as_str(), + "", + ) + .into(), + self.native_global_string( + index_signature.node.value_ty.node.to_string().as_str(), "", ) .into(), @@ -1461,7 +1464,7 @@ impl<'ctx> TypedResultWalker<'ctx> for LLVMCodeGenContext<'ctx> { .expect(kcl_error::INTERNAL_ERROR_MSG); let string_ptr_value = self.native_global_string(name, "").into(); let type_str_ptr_value = self - .native_global_string(&schema_attr.type_str.node, "") + .native_global_string(&schema_attr.ty.node.to_string(), "") .into(); self.build_void_call( &ApiFunc::kclvm_config_attr_map.name(), diff --git a/kclvm/parser/src/parser/expr.rs b/kclvm/parser/src/parser/expr.rs index 26b93bd6e..6ad169a0c 100644 --- a/kclvm/parser/src/parser/expr.rs +++ b/kclvm/parser/src/parser/expr.rs @@ -1912,7 +1912,6 @@ impl<'a> Parser<'a> { self.bump_keyword(kw::Lambda); let mut args = None; - let mut return_type_str = None; let mut return_ty = None; // schema_arguments @@ -1928,7 +1927,6 @@ impl<'a> Parser<'a> { if let TokenKind::RArrow = self.token.kind { self.bump_token(TokenKind::RArrow); let typ = self.parse_type_annotation(); - return_type_str = Some(typ.node.to_string()); return_ty = Some(typ); } @@ -1974,7 +1972,6 @@ impl<'a> Parser<'a> { Box::new(Node::node( Expr::Lambda(LambdaExpr { args, - return_type_str, return_ty, body: stmt_list, }), diff --git a/kclvm/parser/src/parser/stmt.rs b/kclvm/parser/src/parser/stmt.rs index 9d8d11107..24997f0a2 100644 --- a/kclvm/parser/src/parser/stmt.rs +++ b/kclvm/parser/src/parser/stmt.rs @@ -267,7 +267,6 @@ impl<'a> Parser<'a> { Stmt::SchemaAttr(SchemaAttr { doc: "".to_string(), name: node_ref!(target.get_name(), targets[0].pos()), - type_str: type_annotation.unwrap(), ty: ty.unwrap(), op: Some(BinOrAugOp::Aug(aug_op)), value: Some(value), @@ -306,12 +305,7 @@ impl<'a> Parser<'a> { self.skip_newlines(); Some(node_ref!( - Stmt::Assign(AssignStmt { - targets, - value, - type_annotation, - ty, - }), + Stmt::Assign(AssignStmt { targets, value, ty }), self.token_span_pos(token, stmt_end_token) )) } else { @@ -322,7 +316,6 @@ impl<'a> Parser<'a> { Stmt::SchemaAttr(SchemaAttr { doc: "".to_string(), name: node_ref!(target.get_names().join("."), targets[0].pos()), - type_str: type_annotation.unwrap(), ty: ty.unwrap(), op: None, value: None, @@ -377,7 +370,6 @@ impl<'a> Parser<'a> { Stmt::Assign(AssignStmt { targets: targets.clone(), value: miss_expr, - type_annotation, ty, }), pos, @@ -833,7 +825,6 @@ impl<'a> Parser<'a> { let mut args = Arguments { args: Vec::new(), defaults: Vec::new(), - type_annotation_list: Vec::new(), ty_list: Vec::new(), }; @@ -869,14 +860,12 @@ impl<'a> Parser<'a> { let name = node_ref!(name, self.token_span_pos(name_pos, name_end)); - let (type_annotation, type_annotation_node) = if let TokenKind::Colon = self.token.kind - { + let type_annotation_node = if let TokenKind::Colon = self.token.kind { self.bump_token(TokenKind::Colon); let typ = self.parse_type_annotation(); - - (Some(node_ref!(typ.node.to_string(), typ.pos())), Some(typ)) + Some(typ) } else { - (None, None) + None }; let default_value = if let TokenKind::Assign = self.token.kind { @@ -887,7 +876,6 @@ impl<'a> Parser<'a> { }; args.args.push(name); - args.type_annotation_list.push(type_annotation); args.ty_list.push(type_annotation_node); args.defaults.push(default_value); // Parameter interval comma @@ -1047,8 +1035,8 @@ impl<'a> Parser<'a> { if let Stmt::Assign(assign) = x.node.clone() { if assign.targets.len() == 1 { let ident = assign.targets[0].clone().node; - if let Some(type_str) = assign.type_annotation { - if !type_str.node.is_empty() { + if let Some(ref type_str) = assign.ty { + if !type_str.node.to_string().is_empty() { body_body.push(node_ref!( Stmt::SchemaAttr(SchemaAttr { doc: "".to_string(), @@ -1056,8 +1044,7 @@ impl<'a> Parser<'a> { ident.get_names().join("."), assign.targets[0].pos() ), - type_str, - ty: assign.ty.unwrap(), + ty: assign.ty.clone().unwrap(), op: Some(BinOrAugOp::Aug(AugOp::Assign)), value: Some(assign.value), is_optional: false, @@ -1212,8 +1199,7 @@ impl<'a> Parser<'a> { self.bump_token(TokenKind::Colon); // Parse the schema attribute type annotation. - let typ = self.parse_type_annotation(); - let type_str = node_ref!(typ.node.to_string(), typ.pos()); + let ty = self.parse_type_annotation(); let op = if self.token.kind == TokenKind::Assign { self.bump_token(TokenKind::Assign); @@ -1234,8 +1220,7 @@ impl<'a> Parser<'a> { SchemaAttr { doc, name, - type_str, - ty: typ, + ty, op, value, is_optional, @@ -1284,14 +1269,10 @@ impl<'a> Parser<'a> { /// LEFT_BRACKETS [NAME COLON] [ELLIPSIS] basic_type RIGHT_BRACKETS /// COLON type [ASSIGN test] NEWLINE fn parse_schema_index_signature(&mut self) -> SchemaIndexSignature { - let (key_name, key_type, any_other) = if matches!(self.token.kind, TokenKind::DotDotDot) { + let (key_name, key_ty, any_other) = if matches!(self.token.kind, TokenKind::DotDotDot) { // bump token `...` self.bump(); - let key_type = { - let typ = self.parse_type_annotation(); - node_ref!(typ.node.to_string(), typ.pos()) - }; - (None, key_type, true) + (None, self.parse_type_annotation(), true) } else { let token = self.token; let expr = self.parse_identifier_expr(); @@ -1300,11 +1281,7 @@ impl<'a> Parser<'a> { let key_name = ident.get_names().join("."); if let TokenKind::CloseDelim(DelimToken::Bracket) = self.token.kind { - let key_type = { - let typ = node_ref!(Type::Named(ident), pos); - node_ref!(typ.node.to_string(), typ.pos()) - }; - (None, key_type, false) + (None, node_ref!(Type::Named(ident), pos), false) } else { self.bump_token(TokenKind::Colon); let any_other = if let TokenKind::DotDotDot = self.token.kind { @@ -1313,19 +1290,14 @@ impl<'a> Parser<'a> { } else { false }; - let key_type = { - let typ = self.parse_type_annotation(); - node_ref!(typ.node.to_string(), typ.pos()) - }; - (Some(key_name), key_type, any_other) + (Some(key_name), self.parse_type_annotation(), any_other) } }; self.bump_token(TokenKind::CloseDelim(DelimToken::Bracket)); self.bump_token(TokenKind::Colon); - let typ = self.parse_type_annotation(); - let value_type = node_ref!(typ.node.to_string(), typ.pos()); + let value_ty = self.parse_type_annotation(); let value = if let TokenKind::Assign = self.token.kind { self.bump(); @@ -1338,9 +1310,8 @@ impl<'a> Parser<'a> { SchemaIndexSignature { key_name, - key_type, - value_type, - value_ty: typ, + key_ty, + value_ty, value, any_other, } 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 ee8b34eee..db43a7927 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,5 +1,6 @@ --- source: parser/src/tests/ast.rs +assertion_line: 36 expression: "crate::tests::parsing_file_ast_json(\"hello.k\", r####\"a=123\"####)" --- -{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":123}}},"filename":"hello.k","line":1,"column":2,"end_line":1,"end_column":5},"type_annotation":null,"ty":null}},"filename":"hello.k","line":1,"column":0,"end_line":1,"end_column":5}],"comments":[]} +{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":123}}},"filename":"hello.k","line":1,"column":2,"end_line":1,"end_column":5},"ty":null}},"filename":"hello.k","line":1,"column":0,"end_line":1,"end_column":5}],"comments":[]} 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 5907813d7..5913a174f 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,5 +1,6 @@ --- 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 \"####)" --- -{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":5},"type_annotation":null,"ty":null}},"filename":"hello.k","line":3,"column":0,"end_line":3,"end_column":5},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":5,"column":4,"end_line":5,"end_column":5},"type_annotation":null,"ty":null}},"filename":"hello.k","line":5,"column":0,"end_line":5,"end_column":5},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":3}}},"filename":"hello.k","line":7,"column":4,"end_line":7,"end_column":5},"type_annotation":null,"ty":null}},"filename":"hello.k","line":7,"column":0,"end_line":7,"end_column":5}],"comments":[{"node":{"text":"# comment1"},"filename":"hello.k","line":2,"column":0,"end_line":2,"end_column":10},{"node":{"text":"# comment22"},"filename":"hello.k","line":4,"column":0,"end_line":4,"end_column":11},{"node":{"text":"# comment333"},"filename":"hello.k","line":6,"column":0,"end_line":6,"end_column":12},{"node":{"text":"# comment4444"},"filename":"hello.k","line":7,"column":6,"end_line":7,"end_column":19}]} +{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":5},"ty":null}},"filename":"hello.k","line":3,"column":0,"end_line":3,"end_column":5},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":5,"column":4,"end_line":5,"end_column":5},"ty":null}},"filename":"hello.k","line":5,"column":0,"end_line":5,"end_column":5},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":3}}},"filename":"hello.k","line":7,"column":4,"end_line":7,"end_column":5},"ty":null}},"filename":"hello.k","line":7,"column":0,"end_line":7,"end_column":5}],"comments":[{"node":{"text":"# comment1"},"filename":"hello.k","line":2,"column":0,"end_line":2,"end_column":10},{"node":{"text":"# comment22"},"filename":"hello.k","line":4,"column":0,"end_line":4,"end_column":11},{"node":{"text":"# comment333"},"filename":"hello.k","line":6,"column":0,"end_line":6,"end_column":12},{"node":{"text":"# comment4444"},"filename":"hello.k","line":7,"column":6,"end_line":7,"end_column":19}]} 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 27eb89f71..2c4445ed8 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,5 +1,6 @@ --- 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 \"####)" --- -{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":10}}},"filename":"hello.k","line":2,"column":4,"end_line":2,"end_column":6},"type_annotation":null,"ty":null}},"filename":"hello.k","line":2,"column":0,"end_line":2,"end_column":6},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":12}}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":6},"type_annotation":null,"ty":null}},"filename":"hello.k","line":3,"column":0,"end_line":3,"end_column":6},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":0}}},"filename":"hello.k","line":4,"column":13,"end_line":4,"end_column":14},"type_annotation":null,"ty":null}},"filename":"hello.k","line":4,"column":0,"end_line":4,"end_column":14},{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":5,"column":36,"end_line":5,"end_column":37},"type_annotation":null,"ty":null}},"filename":"hello.k","line":5,"column":23,"end_line":5,"end_column":37}],"cond":{"node":{"Binary":{"left":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":5,"column":3,"end_line":5,"end_column":4}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":5,"column":3,"end_line":5,"end_column":4},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"Bin":"Or"},"right":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"b","filename":"hello.k","line":5,"column":14,"end_line":5,"end_column":15}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":5,"column":14,"end_line":5,"end_column":15},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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}}},"filename":"hello.k","line":5,"column":3,"end_line":5,"end_column":21},"orelse":[{"node":{"If":{"body":[{"node":{"Assign":{"targets":[{"node":{"names":[{"node":"_condition","filename":"hello.k","line":6,"column":26,"end_line":6,"end_column":36}],"pkgpath":"","ctx":"Store"},"filename":"hello.k","line":6,"column":26,"end_line":6,"end_column":36}],"value":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":6,"column":39,"end_line":6,"end_column":40},"type_annotation":null,"ty":null}},"filename":"hello.k","line":6,"column":26,"end_line":6,"end_column":40}],"cond":{"node":{"Binary":{"left":{"node":{"Compare":{"left":{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":10}}},"filename":"hello.k","line":6,"column":10,"end_line":6,"end_column":12}]}},"filename":"hello.k","line":6,"column":5,"end_line":6,"end_column":24},"op":{"Bin":"And"},"right":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":12}}},"filename":"hello.k","line":6,"column":22,"end_line":6,"end_column":24}]}},"filename":"hello.k","line":6,"column":17,"end_line":6,"end_column":24}}},"filename":"hello.k","line":6,"column":5,"end_line":6,"end_column":24},"orelse":[]}},"filename":"hello.k","line":6,"column":0,"end_line":7,"end_column":0}]}},"filename":"hello.k","line":5,"column":0,"end_line":7,"end_column":0},{"node":{"Assign":{"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":{"node":{"Identifier":{"names":[{"node":"_condition","filename":"hello.k","line":7,"column":12,"end_line":7,"end_column":22}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":7,"column":12,"end_line":7,"end_column":22},"type_annotation":null,"ty":null}},"filename":"hello.k","line":7,"column":0,"end_line":7,"end_column":22}],"comments":[]} +{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":10}}},"filename":"hello.k","line":2,"column":4,"end_line":2,"end_column":6},"ty":null}},"filename":"hello.k","line":2,"column":0,"end_line":2,"end_column":6},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":12}}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":6},"ty":null}},"filename":"hello.k","line":3,"column":0,"end_line":3,"end_column":6},{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":0}}},"filename":"hello.k","line":4,"column":13,"end_line":4,"end_column":14},"ty":null}},"filename":"hello.k","line":4,"column":0,"end_line":4,"end_column":14},{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":5,"column":36,"end_line":5,"end_column":37},"ty":null}},"filename":"hello.k","line":5,"column":23,"end_line":5,"end_column":37}],"cond":{"node":{"Binary":{"left":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":5,"column":3,"end_line":5,"end_column":4}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":5,"column":3,"end_line":5,"end_column":4},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"Bin":"Or"},"right":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"b","filename":"hello.k","line":5,"column":14,"end_line":5,"end_column":15}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":5,"column":14,"end_line":5,"end_column":15},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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}}},"filename":"hello.k","line":5,"column":3,"end_line":5,"end_column":21},"orelse":[{"node":{"If":{"body":[{"node":{"Assign":{"targets":[{"node":{"names":[{"node":"_condition","filename":"hello.k","line":6,"column":26,"end_line":6,"end_column":36}],"pkgpath":"","ctx":"Store"},"filename":"hello.k","line":6,"column":26,"end_line":6,"end_column":36}],"value":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":6,"column":39,"end_line":6,"end_column":40},"ty":null}},"filename":"hello.k","line":6,"column":26,"end_line":6,"end_column":40}],"cond":{"node":{"Binary":{"left":{"node":{"Compare":{"left":{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":10}}},"filename":"hello.k","line":6,"column":10,"end_line":6,"end_column":12}]}},"filename":"hello.k","line":6,"column":5,"end_line":6,"end_column":24},"op":{"Bin":"And"},"right":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":12}}},"filename":"hello.k","line":6,"column":22,"end_line":6,"end_column":24}]}},"filename":"hello.k","line":6,"column":17,"end_line":6,"end_column":24}}},"filename":"hello.k","line":6,"column":5,"end_line":6,"end_column":24},"orelse":[]}},"filename":"hello.k","line":6,"column":0,"end_line":7,"end_column":0}]}},"filename":"hello.k","line":5,"column":0,"end_line":7,"end_column":0},{"node":{"Assign":{"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":{"node":{"Identifier":{"names":[{"node":"_condition","filename":"hello.k","line":7,"column":12,"end_line":7,"end_column":22}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":7,"column":12,"end_line":7,"end_column":22},"ty":null}},"filename":"hello.k","line":7,"column":0,"end_line":7,"end_column":22}],"comments":[]} 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 b9c17adf3..90c6b984e 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,5 +1,6 @@ --- 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 \"####)" --- -{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"Config":{"items":[{"node":{"key":null,"value":{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"key","filename":"hello.k","line":3,"column":7,"end_line":3,"end_column":10}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":3,"column":7,"end_line":3,"end_column":10},"value":{"node":{"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":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":{"ConfigIfEntry":{"if_cond":{"node":{"Compare":{"left":{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"ConfigIfEntry":{"if_cond":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":456}}},"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":{"key":{"node":{"Identifier":{"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":{"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":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},"type_annotation":null,"ty":null}},"filename":"hello.k","line":2,"column":0,"end_line":5,"end_column":1}],"comments":[]} +{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"Config":{"items":[{"node":{"key":null,"value":{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"key","filename":"hello.k","line":3,"column":7,"end_line":3,"end_column":10}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":3,"column":7,"end_line":3,"end_column":10},"value":{"node":{"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":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":{"ConfigIfEntry":{"if_cond":{"node":{"Compare":{"left":{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"ConfigIfEntry":{"if_cond":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":456}}},"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":{"key":{"node":{"Identifier":{"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":{"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":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":0,"end_line":5,"end_column":1}],"comments":[]} 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 ef1b37449..e1c6587b1 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,5 +1,6 @@ --- 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 \"####)" --- -{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"Expr":{"exprs":[{"node":{"List":{"elts":[],"ctx":"Load"}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":6}]}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":6},{"node":{"SchemaAttr":{"doc":"","name":{"node":"a","filename":"hello.k","line":8,"column":4,"end_line":8,"end_column":5},"type_str":{"node":"int","filename":"hello.k","line":8,"column":7,"end_line":8,"end_column":10},"op":null,"value":null,"is_optional":false,"decorators":[],"ty":{"node":{"Basic":"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":{"SchemaAttr":{"doc":"","name":{"node":"b","filename":"hello.k","line":9,"column":4,"end_line":9,"end_column":5},"type_str":{"node":"str","filename":"hello.k","line":9,"column":8,"end_line":9,"end_column":11},"op":null,"value":null,"is_optional":true,"decorators":[],"ty":{"node":{"Basic":"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":{"SchemaAttr":{"doc":"","name":{"node":"c","filename":"hello.k","line":10,"column":4,"end_line":10,"end_column":5},"type_str":{"node":"int","filename":"hello.k","line":10,"column":7,"end_line":10,"end_column":10},"op":{"Aug":"Assign"},"value":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":0}}},"filename":"hello.k","line":10,"column":13,"end_line":10,"end_column":14},"is_optional":false,"decorators":[],"ty":{"node":{"Basic":"Int"},"filename":"hello.k","line":10,"column":7,"end_line":10,"end_column":10}}},"filename":"hello.k","line":10,"column":4,"end_line":10,"end_column":14},{"node":{"SchemaAttr":{"doc":"","name":{"node":"d","filename":"hello.k","line":11,"column":4,"end_line":11,"end_column":5},"type_str":{"node":"str","filename":"hello.k","line":11,"column":8,"end_line":11,"end_column":11},"op":{"Aug":"Assign"},"value":{"node":{"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":{"Basic":"Str"},"filename":"hello.k","line":11,"column":8,"end_line":11,"end_column":11}}},"filename":"hello.k","line":11,"column":4,"end_line":13,"end_column":0},{"node":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":13,"column":5,"end_line":13,"end_column":6}],"pkgpath":"","ctx":"Load"}},"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":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"Identifier":{"names":[{"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":{"Identifier":{"names":[{"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":{"Identifier":{"names":[{"node":"c","filename":"hello.k","line":14,"column":11,"end_line":14,"end_column":12}],"pkgpath":"","ctx":"Load"}},"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":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":19,"column":8,"end_line":19,"end_column":9}],"pkgpath":"","ctx":"Load"}},"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":{"Expr":{"exprs":[{"node":{"ListComp":{"elt":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":21,"column":5,"end_line":21,"end_column":6}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":21,"column":5,"end_line":21,"end_column":6},"generators":[{"node":{"targets":[{"node":{"names":[{"node":"a","filename":"hello.k","line":21,"column":11,"end_line":21,"end_column":12}],"pkgpath":"","ctx":"Load"},"filename":"hello.k","line":21,"column":11,"end_line":21,"end_column":12}],"iter":{"node":{"List":{"elts":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":21,"column":17,"end_line":21,"end_column":18},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":21,"column":20,"end_line":21,"end_column":21},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"Expr":{"exprs":[{"node":{"ListComp":{"elt":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":23,"column":8,"end_line":23,"end_column":9}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":23,"column":8,"end_line":23,"end_column":9},"generators":[{"node":{"targets":[{"node":{"names":[{"node":"a","filename":"hello.k","line":23,"column":14,"end_line":23,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"hello.k","line":23,"column":14,"end_line":23,"end_column":15}],"iter":{"node":{"List":{"elts":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":23,"column":20,"end_line":23,"end_column":21},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":23,"column":23,"end_line":23,"end_column":24},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":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":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":27,"column":8,"end_line":27,"end_column":9}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":27,"column":8,"end_line":27,"end_column":9},"ops":["Gt"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"StringLit":{"is_long_string":false,"raw_value":"\"msg\"","value":"msg"}},"filename":"hello.k","line":27,"column":15,"end_line":27,"end_column":20}},"filename":"hello.k","line":27,"column":8,"end_line":27,"end_column":20},{"node":{"test":{"node":{"Identifier":{"names":[{"node":"name","filename":"hello.k","line":28,"column":8,"end_line":28,"end_column":12}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":28,"column":8,"end_line":28,"end_column":12},"if_cond":null,"msg":null},"filename":"hello.k","line":28,"column":8,"end_line":28,"end_column":12},{"node":{"test":{"node":{"Unary":{"op":"Not","operand":{"node":{"NameConstantLit":{"value":"None"}},"filename":"hello.k","line":28,"column":17,"end_line":28,"end_column":21}}},"filename":"hello.k","line":28,"column":13,"end_line":28,"end_column":21},"if_cond":null,"msg":{"node":{"StringLit":{"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":13,"end_line":28,"end_column":37}],"index_signature":{"node":{"key_name":null,"key_type":{"node":"str","filename":"hello.k","line":7,"column":8,"end_line":7,"end_column":11},"value_type":{"node":"int","filename":"hello.k","line":7,"column":14,"end_line":7,"end_column":17},"value":null,"any_other":true,"value_ty":{"node":{"Basic":"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","line":2,"column":0,"end_line":29,"end_column":8}],"comments":[]} +{"filename":"hello.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"Expr":{"exprs":[{"node":{"List":{"elts":[],"ctx":"Load"}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":6}]}},"filename":"hello.k","line":3,"column":4,"end_line":3,"end_column":6},{"node":{"SchemaAttr":{"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":{"Basic":"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":{"SchemaAttr":{"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":{"Basic":"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":{"SchemaAttr":{"doc":"","name":{"node":"c","filename":"hello.k","line":10,"column":4,"end_line":10,"end_column":5},"op":{"Aug":"Assign"},"value":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":0}}},"filename":"hello.k","line":10,"column":13,"end_line":10,"end_column":14},"is_optional":false,"decorators":[],"ty":{"node":{"Basic":"Int"},"filename":"hello.k","line":10,"column":7,"end_line":10,"end_column":10}}},"filename":"hello.k","line":10,"column":4,"end_line":10,"end_column":14},{"node":{"SchemaAttr":{"doc":"","name":{"node":"d","filename":"hello.k","line":11,"column":4,"end_line":11,"end_column":5},"op":{"Aug":"Assign"},"value":{"node":{"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":{"Basic":"Str"},"filename":"hello.k","line":11,"column":8,"end_line":11,"end_column":11}}},"filename":"hello.k","line":11,"column":4,"end_line":13,"end_column":0},{"node":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":13,"column":5,"end_line":13,"end_column":6}],"pkgpath":"","ctx":"Load"}},"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":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"Identifier":{"names":[{"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":{"Identifier":{"names":[{"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":{"Identifier":{"names":[{"node":"c","filename":"hello.k","line":14,"column":11,"end_line":14,"end_column":12}],"pkgpath":"","ctx":"Load"}},"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":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"Expr":{"exprs":[{"node":{"List":{"elts":[{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":19,"column":8,"end_line":19,"end_column":9}],"pkgpath":"","ctx":"Load"}},"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":{"Expr":{"exprs":[{"node":{"ListComp":{"elt":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":21,"column":5,"end_line":21,"end_column":6}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":21,"column":5,"end_line":21,"end_column":6},"generators":[{"node":{"targets":[{"node":{"names":[{"node":"a","filename":"hello.k","line":21,"column":11,"end_line":21,"end_column":12}],"pkgpath":"","ctx":"Load"},"filename":"hello.k","line":21,"column":11,"end_line":21,"end_column":12}],"iter":{"node":{"List":{"elts":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":21,"column":17,"end_line":21,"end_column":18},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":21,"column":20,"end_line":21,"end_column":21},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"Expr":{"exprs":[{"node":{"ListComp":{"elt":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":23,"column":8,"end_line":23,"end_column":9}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":23,"column":8,"end_line":23,"end_column":9},"generators":[{"node":{"targets":[{"node":{"names":[{"node":"a","filename":"hello.k","line":23,"column":14,"end_line":23,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"hello.k","line":23,"column":14,"end_line":23,"end_column":15}],"iter":{"node":{"List":{"elts":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"hello.k","line":23,"column":20,"end_line":23,"end_column":21},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"hello.k","line":23,"column":23,"end_line":23,"end_column":24},{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":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":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"a","filename":"hello.k","line":27,"column":8,"end_line":27,"end_column":9}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":27,"column":8,"end_line":27,"end_column":9},"ops":["Gt"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"StringLit":{"is_long_string":false,"raw_value":"\"msg\"","value":"msg"}},"filename":"hello.k","line":27,"column":15,"end_line":27,"end_column":20}},"filename":"hello.k","line":27,"column":8,"end_line":27,"end_column":20},{"node":{"test":{"node":{"Identifier":{"names":[{"node":"name","filename":"hello.k","line":28,"column":8,"end_line":28,"end_column":12}],"pkgpath":"","ctx":"Load"}},"filename":"hello.k","line":28,"column":8,"end_line":28,"end_column":12},"if_cond":null,"msg":null},"filename":"hello.k","line":28,"column":8,"end_line":28,"end_column":12},{"node":{"test":{"node":{"Unary":{"op":"Not","operand":{"node":{"NameConstantLit":{"value":"None"}},"filename":"hello.k","line":28,"column":17,"end_line":28,"end_column":21}}},"filename":"hello.k","line":28,"column":13,"end_line":28,"end_column":21},"if_cond":null,"msg":{"node":{"StringLit":{"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":13,"end_line":28,"end_column":37}],"index_signature":{"node":{"key_name":null,"value":null,"any_other":true,"key_ty":{"node":{"Basic":"Str"},"filename":"hello.k","line":7,"column":8,"end_line":7,"end_column":11},"value_ty":{"node":{"Basic":"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","line":2,"column":0,"end_line":29,"end_column":8}],"comments":[]} diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_0.snap index ab7e57f1b..de7843857 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_0.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 170 expression: "crate::tests::parsing_module_string(r#\"a = \"#)" --- Module { @@ -44,7 +45,6 @@ Module { end_line: 1, end_column: 4, }, - type_annotation: None, ty: None, }, ), diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_2.snap index f6c5347e5..c14a848ec 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_2.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 172 expression: "crate::tests::parsing_module_string(r#\"a: int =\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 8, }, - type_annotation: Some( - Node { - node: "int", - filename: "", - line: 1, - column: 3, - end_line: 1, - end_column: 6, - }, - ), ty: Some( Node { node: Basic( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_3.snap index 6b14867d1..ae525294e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_3.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 173 expression: "crate::tests::parsing_module_string(r#\"a: a = 1\"#)" --- Module { @@ -49,16 +50,6 @@ Module { end_line: 1, end_column: 8, }, - type_annotation: Some( - Node { - node: "a", - filename: "", - line: 1, - column: 3, - end_line: 1, - end_column: 4, - }, - ), ty: Some( Node { node: Named( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_4.snap index 96ca85bd4..713264e42 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_4.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 174 expression: "crate::tests::parsing_module_string(r#\"a:\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 2, }, - type_annotation: Some( - Node { - node: "any", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 2, - }, - ), ty: Some( Node { node: Any, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_5.snap index e72059f72..a269227ee 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_5.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 175 expression: "crate::tests::parsing_module_string(r#\"a = b = \"#)" --- Module { @@ -65,7 +66,6 @@ Module { end_line: 1, end_column: 8, }, - type_annotation: None, ty: None, }, ), diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_6.snap index 3f47ea31f..0a9b5bada 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_6.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 176 expression: "crate::tests::parsing_module_string(r#\"a() = b. = c\"#)" --- Module { @@ -77,7 +78,6 @@ Module { end_line: 1, end_column: 12, }, - type_annotation: None, ty: None, }, ), diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_7.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_7.snap index ee8571629..80ef40aef 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_7.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_7.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 177 expression: "crate::tests::parsing_module_string(r#\"a: () = 0\"#)" --- Module { @@ -49,16 +50,6 @@ Module { end_line: 1, end_column: 9, }, - type_annotation: Some( - Node { - node: "()", - filename: "", - line: 1, - column: 3, - end_line: 1, - end_column: 5, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_8.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_8.snap index ee8571629..40632b2db 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_8.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__assign_stmt_recovery_8.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 178 expression: "crate::tests::parsing_module_string(r#\"a: () = 0\"#)" --- Module { @@ -49,16 +50,6 @@ Module { end_line: 1, end_column: 9, }, - type_annotation: Some( - Node { - node: "()", - filename: "", - line: 1, - column: 3, - end_line: 1, - end_column: 5, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_0.snap index f838319dc..cc0ed2331 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_0.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 303 expression: "crate::tests::parsing_module_string(r#\"a:(\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 3, }, - type_annotation: Some( - Node { - node: "(any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 3, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_1.snap index 58567de8e..e49b03b5b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_1.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 304 expression: "crate::tests::parsing_module_string(r#\"a:(i\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 4, }, - type_annotation: Some( - Node { - node: "(i, any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 4, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_10.snap index 9c0dd89bb..73cb8778e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_10.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 313 expression: "crate::tests::parsing_module_string(r#\"a:({\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 4, }, - type_annotation: Some( - Node { - node: "({any:any})", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 4, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_11.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_11.snap index 217e8de3d..5cfbba9c7 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_11.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_11.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 314 expression: "crate::tests::parsing_module_string(r#\"a:({i\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 5, }, - type_annotation: Some( - Node { - node: "({i:any})", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 5, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_12.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_12.snap index c2a5cbb66..0eb248a85 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_12.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_12.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 315 expression: "crate::tests::parsing_module_string(r#\"a:({i:\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 6, }, - type_annotation: Some( - Node { - node: "({i:any})", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 6, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_13.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_13.snap index 53e0d6572..68ec7d35f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_13.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_13.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 316 expression: "crate::tests::parsing_module_string(r#\"a:({i:i\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 7, }, - type_annotation: Some( - Node { - node: "({i:i})", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 7, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_14.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_14.snap index 48f27b4b1..31246010e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_14.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_14.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 317 expression: "crate::tests::parsing_module_string(r#\"a:({i:int\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 9, }, - type_annotation: Some( - Node { - node: "({i:int})", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 9, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_15.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_15.snap index 5ec2c2895..3731cbe38 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_15.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_15.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 318 expression: "crate::tests::parsing_module_string(r#\"a:({i:int]\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 10, }, - type_annotation: Some( - Node { - node: "({i:int}, any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 10, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_16.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_16.snap index 26b49cd1d..02ae0f14a 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_16.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_16.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 319 expression: "crate::tests::parsing_module_string(r#\"a:({str:int]\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 12, }, - type_annotation: Some( - Node { - node: "({str:int}, any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 12, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_17.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_17.snap index 77cda0200..99eba5b4a 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_17.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_17.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 320 expression: "crate::tests::parsing_module_string(r#\"a:({str:int}\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 12, }, - type_annotation: Some( - Node { - node: "({str:int}, any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 12, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_18.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_18.snap index 2f1112f42..fd30dc8de 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_18.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_18.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 321 expression: "crate::tests::parsing_module_string(r#\"a:({str:int} ->\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 15, }, - type_annotation: Some( - Node { - node: "({str:int}, any, any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 15, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_19.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_19.snap index f5d72e9f1..fafafc948 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_19.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_19.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 322 expression: "crate::tests::parsing_module_string(r#\"a:({str:int}) -> i\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 18, }, - type_annotation: Some( - Node { - node: "({str:int}) -> i", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 18, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_2.snap index cf53073c4..9886a7c98 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_2.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 305 expression: "crate::tests::parsing_module_string(r#\"a:(int\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 6, }, - type_annotation: Some( - Node { - node: "(int, any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 6, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_20.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_20.snap index 8aae7a8ab..4643f67e5 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_20.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_20.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 323 expression: "crate::tests::parsing_module_string(r#\"a:(str|int) -> i\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 16, }, - type_annotation: Some( - Node { - node: "(str | int) -> i", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 16, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_21.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_21.snap index bf083894d..b3ccd5a8a 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_21.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_21.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 324 expression: "crate::tests::parsing_module_string(r#\"a:(str|int, int) -> i\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 21, }, - type_annotation: Some( - Node { - node: "(str | int, int) -> i", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 21, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_22.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_22.snap index 44886cca1..7cf0505a3 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_22.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_22.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 325 expression: "crate::tests::parsing_module_string(r#\"a:(str|int, int|\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 16, }, - type_annotation: Some( - Node { - node: "(str | int, int | any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 16, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_23.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_23.snap index 8b5dfd177..27c647d88 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_23.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_23.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 326 expression: "crate::tests::parsing_module_string(r#\"a:(str|int, int|) ->\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 20, }, - type_annotation: Some( - Node { - node: "(str | int, int | any, any, any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 20, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_3.snap index f62ec6b49..089985ad5 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_3.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 306 expression: "crate::tests::parsing_module_string(r#\"a:i)\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 4, }, - type_annotation: Some( - Node { - node: "i", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 3, - }, - ), ty: Some( Node { node: Named( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_4.snap index 3f080499d..7090fb529 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_4.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 307 expression: "crate::tests::parsing_module_string(r#\"a:([i\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 5, }, - type_annotation: Some( - Node { - node: "([i])", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 5, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_5.snap index 96af5f0bb..dce820c2b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_5.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 308 expression: "crate::tests::parsing_module_string(r#\"a:([i:\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 6, }, - type_annotation: Some( - Node { - node: "([i], any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 6, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_6.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_6.snap index c59318617..1958b3b5d 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_6.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_6.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 309 expression: "crate::tests::parsing_module_string(r#\"a:([i]\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 6, }, - type_annotation: Some( - Node { - node: "([i], any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 6, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_7.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_7.snap index 13aff0a85..0c72fe05e 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_7.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_7.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 310 expression: "crate::tests::parsing_module_string(r#\"a:([int]\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 8, }, - type_annotation: Some( - Node { - node: "([int], any)", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 8, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_8.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_8.snap index b765aa837..98a37fc95 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_8.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_8.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 311 expression: "crate::tests::parsing_module_string(r#\"a:([int\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 7, }, - type_annotation: Some( - Node { - node: "([int])", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 7, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_9.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_9.snap index ee9fab1ac..0105b2ad3 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_9.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__fn_ty_annotation_recovery_9.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 312 expression: "crate::tests::parsing_module_string(r#\"a:({}\"#)" --- Module { @@ -44,16 +45,6 @@ Module { end_line: 1, end_column: 5, }, - type_annotation: Some( - Node { - node: "({any:any})", - filename: "", - line: 1, - column: 2, - end_line: 1, - end_column: 5, - }, - ), ty: Some( Node { node: Function( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_0.snap index 78ac7805c..2a542bb56 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_0.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 199 expression: "crate::tests::parsing_module_string(r#\"if True a = 1\"#)" --- Module { @@ -44,7 +45,6 @@ Module { end_line: 1, end_column: 13, }, - type_annotation: None, ty: None, }, ), diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_1.snap index f0f839de9..d53a4c341 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_1.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 200 expression: "crate::tests::parsing_module_string(r#\"if True: a = 1 else if b = 2\"#)" --- Module { @@ -53,7 +54,6 @@ Module { end_line: 1, end_column: 14, }, - type_annotation: None, ty: None, }, ), @@ -118,7 +118,6 @@ Module { end_line: 1, end_column: 28, }, - type_annotation: None, ty: None, }, ), diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_2.snap index 28c00159e..0825e61de 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_2.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 201 expression: "crate::tests::parsing_module_string(r#\"if : a = 1\"#)" --- Module { @@ -53,7 +54,6 @@ Module { end_line: 1, end_column: 10, }, - type_annotation: None, ty: None, }, ), diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_3.snap index f753b79dd..08649b203 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_3.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 202 expression: "crate::tests::parsing_module_string(r#\"if True: a = 1 else b = 2\"#)" --- Module { @@ -53,7 +54,6 @@ Module { end_line: 1, end_column: 14, }, - type_annotation: None, ty: None, }, ), @@ -109,7 +109,6 @@ Module { end_line: 1, end_column: 25, }, - type_annotation: None, ty: None, }, ), diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_4.snap index ffc1fc9bc..1919ee82f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__if_stmt_recovery_4.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 203 expression: "crate::tests::parsing_module_string(r#\"if True: else: b = 2\"#)" --- Module { @@ -53,16 +54,6 @@ Module { end_line: 1, end_column: 20, }, - type_annotation: Some( - Node { - node: "b", - filename: "", - line: 1, - column: 15, - end_line: 1, - end_column: 16, - }, - ), ty: Some( Node { node: Named( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_0.snap index dc82a0813..72e7e6216 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_0.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 158 +assertion_line: 161 expression: "crate::tests::parsing_expr_string(r#\"lambda\"#)" --- Node { @@ -11,7 +11,6 @@ Node { node: Arguments { args: [], defaults: [], - type_annotation_list: [], ty_list: [], }, filename: "", @@ -21,7 +20,6 @@ Node { end_column: 6, }, ), - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_1.snap index 570cfb3d7..01fc43f47 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_1.snap @@ -1,13 +1,12 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 159 +assertion_line: 162 expression: "crate::tests::parsing_expr_string(r#\"lambda {\"#)" --- Node { node: Lambda( LambdaExpr { args: None, - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_2.snap index 09c83a9f8..d591a8a1b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_2.snap @@ -1,13 +1,12 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 160 +assertion_line: 163 expression: "crate::tests::parsing_expr_string(r#\"lambda {}\"#)" --- Node { node: Lambda( LambdaExpr { args: None, - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_3.snap index 27c65c7d0..4995fa293 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_3.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 161 +assertion_line: 164 expression: "crate::tests::parsing_expr_string(r#\"{lambda}\"#)" --- Node { @@ -42,9 +42,6 @@ Node { defaults: [ None, ], - type_annotation_list: [ - None, - ], ty_list: [ None, ], @@ -56,7 +53,6 @@ Node { end_column: 8, }, ), - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_4.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_4.snap index 8a4ad8854..b125d7154 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_4.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_4.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 162 +assertion_line: 165 expression: "crate::tests::parsing_expr_string(r#\"{lambda{}\"#)" --- Node { @@ -14,7 +14,6 @@ Node { node: Lambda( LambdaExpr { args: None, - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_5.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_5.snap index b9df5c3c8..97642b554 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_5.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__lambda_recovery_5.snap @@ -1,6 +1,6 @@ --- source: parser/src/tests/error_recovery.rs -assertion_line: 163 +assertion_line: 166 expression: "crate::tests::parsing_expr_string(r#\"{lambda a{}\"#)" --- Node { @@ -42,9 +42,6 @@ Node { defaults: [ None, ], - type_annotation_list: [ - None, - ], ty_list: [ None, ], @@ -56,7 +53,6 @@ Node { end_column: 9, }, ), - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__rule_stmt_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__rule_stmt_recovery_2.snap index 079a05e7d..ab4335251 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__rule_stmt_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__rule_stmt_recovery_2.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 292 expression: "crate::tests::parsing_module_string(r#\"rule A[\"#)" --- Module { @@ -28,7 +29,6 @@ Module { node: Arguments { args: [], defaults: [], - type_annotation_list: [], ty_list: [], }, filename: "", diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_10.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_10.snap index 82973c143..1b41e73ba 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_10.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_10.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 220 expression: "crate::tests::parsing_module_string(r#\"schema A:\n[str:]: []\"#)" --- Module { @@ -65,16 +66,6 @@ Module { end_line: 2, end_column: 10, }, - type_annotation: Some( - Node { - node: "[]", - filename: "", - line: 2, - column: 8, - end_line: 2, - end_column: 10, - }, - ), ty: Some( Node { node: List( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_11.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_11.snap index 1cd474009..dedaa1e66 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_11.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_11.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 222 expression: "crate::tests::parsing_module_string(r#\"schema A:\n[str]: str = \"#)" --- Module { @@ -65,16 +66,6 @@ Module { end_line: 2, end_column: 13, }, - type_annotation: Some( - Node { - node: "str", - filename: "", - line: 2, - column: 7, - end_line: 2, - end_column: 10, - }, - ), ty: Some( Node { node: Basic( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_12.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_12.snap index e1dad6968..fd8aa72d7 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_12.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_12.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 224 expression: "crate::tests::parsing_module_string(r#\"schema A:\n[str]: = \"#)" --- Module { @@ -65,16 +66,6 @@ Module { end_line: 2, end_column: 9, }, - type_annotation: Some( - Node { - node: "any", - filename: "", - line: 2, - column: 7, - end_line: 2, - end_column: 8, - }, - ), ty: Some( Node { node: Any, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_13.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_13.snap index 811d23ddb..b20085b14 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_13.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_13.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 226 expression: "crate::tests::parsing_module_string(r#\"schema A:\n[str]: ''= \"#)" --- Module { @@ -65,16 +66,6 @@ Module { end_line: 2, end_column: 11, }, - type_annotation: Some( - Node { - node: "\"\"", - filename: "", - line: 2, - column: 7, - end_line: 2, - end_column: 9, - }, - ), ty: Some( Node { node: Literal( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_17.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_17.snap index 9bb2449e0..9841b3f98 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_17.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_17.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 234 expression: "crate::tests::parsing_module_string(r#\"schema A:\na: \"#)" --- Module { @@ -74,16 +75,6 @@ Module { end_line: 2, end_column: 3, }, - type_annotation: Some( - Node { - node: "any", - filename: "", - line: 2, - column: 3, - end_line: 2, - end_column: 3, - }, - ), ty: Some( Node { node: Any, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_19.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_19.snap index dcd5cff68..a456bde77 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_19.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_19.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 236 expression: "crate::tests::parsing_module_string(r#\"@deprecated\nschema A:\n a: \"#)" --- Module { @@ -39,14 +40,6 @@ Module { end_line: 3, end_column: 5, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_2.snap index 1aeaf7990..1869dbab7 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_2.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 209 expression: "crate::tests::parsing_module_string(r#\"schema A[\"#)" --- Module { @@ -29,7 +30,6 @@ Module { node: Arguments { args: [], defaults: [], - type_annotation_list: [], ty_list: [], }, filename: "", diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap index 91b163af3..f25921168 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_20.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 239 expression: "crate::tests::parsing_module_string(r#\"@deprecated(\nschema A:\n a: \"#)" --- Module { @@ -39,14 +40,6 @@ Module { end_line: 3, end_column: 5, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap index 91b163af3..f5fc62b5c 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_21.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 242 expression: "crate::tests::parsing_module_string(r#\"@deprecated(\nschema A:\n a: \"#)" --- Module { @@ -39,14 +40,6 @@ Module { end_line: 3, end_column: 5, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_22.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_22.snap index 5e63a99fc..cdd1cdef6 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_22.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_22.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 245 expression: "crate::tests::parsing_module_string(r#\"@deprecated(a\nschema A:\n a: \"#)" --- Module { @@ -39,14 +40,6 @@ Module { end_line: 3, end_column: 5, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap index ae158d887..71c00d226 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_23.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 248 expression: "crate::tests::parsing_module_string(r#\"@deprecated(a,\nschema A:\n a: \"#)" --- Module { @@ -39,14 +40,6 @@ Module { end_line: 3, end_column: 5, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap index 55fc3ff87..0bb76d007 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_24.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 251 expression: "crate::tests::parsing_module_string(r#\"@deprecated((),\nschema A:\n a: \"#)" --- Module { @@ -39,14 +40,6 @@ Module { end_line: 3, end_column: 5, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 7, - end_line: 3, - end_column: 7, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_29.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_29.snap index 8f5d8d555..04695f256 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_29.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_29.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 267 expression: "crate::tests::parsing_module_string(r#\"\nschema A:\n @\"#)" --- Module { @@ -39,14 +40,6 @@ Module { end_line: 3, end_column: 5, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 5, - end_line: 3, - end_column: 5, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_31.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_31.snap index 6961534ff..c6be13f8f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_31.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_31.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 273 expression: "crate::tests::parsing_module_string(r#\"\nschema A:\n [str]: str\n [str]: int\"#)" --- Module { @@ -33,24 +34,31 @@ Module { Node { node: SchemaIndexSignature { key_name: None, - key_type: Node { - node: "str", + value: None, + any_other: false, + key_ty: Node { + node: Named( + Identifier { + names: [ + Node { + node: "str", + filename: "", + line: 4, + column: 5, + end_line: 4, + end_column: 8, + }, + ], + pkgpath: "", + ctx: Load, + }, + ), filename: "", line: 4, column: 5, end_line: 4, end_column: 8, }, - value_type: Node { - node: "int", - filename: "", - line: 4, - column: 11, - end_line: 4, - end_column: 14, - }, - value: None, - any_other: false, value_ty: Node { node: Basic( Int, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_32.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_32.snap index cc938b07d..e8eaa3848 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_32.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_32.snap @@ -40,14 +40,6 @@ Module { end_line: 3, end_column: 10, }, - type_str: Node { - node: "str", - filename: "", - line: 3, - column: 12, - end_line: 3, - end_column: 15, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_33.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_33.snap index 76462a4cc..30f0e4146 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_33.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_33.snap @@ -49,14 +49,6 @@ Module { end_line: 4, end_column: 10, }, - type_str: Node { - node: "str", - filename: "", - line: 4, - column: 12, - end_line: 4, - end_column: 15, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_35.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_35.snap index 21f8d78a7..5d5215a7b 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_35.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_35.snap @@ -40,14 +40,6 @@ Module { end_line: 3, end_column: 10, }, - type_str: Node { - node: "any", - filename: "", - line: 3, - column: 11, - end_line: 3, - end_column: 11, - }, op: None, value: None, is_optional: false, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_7.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_7.snap index 255d3fa1d..a235208a7 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_7.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_7.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 214 expression: "crate::tests::parsing_module_string(r#\"schema A:\na:: int\"#)" --- Module { @@ -74,16 +75,6 @@ Module { end_line: 2, end_column: 7, }, - type_annotation: Some( - Node { - node: "any", - filename: "", - line: 2, - column: 2, - end_line: 2, - end_column: 3, - }, - ), ty: Some( Node { node: Any, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_8.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_8.snap index d4a70e959..4e7515c44 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_8.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_8.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 216 expression: "crate::tests::parsing_module_string(r#\"schema A:\na: int =\"#)" --- Module { @@ -74,16 +75,6 @@ Module { end_line: 2, end_column: 8, }, - type_annotation: Some( - Node { - node: "int", - filename: "", - line: 2, - column: 3, - end_line: 2, - end_column: 6, - }, - ), ty: Some( Node { node: Basic( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_9.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_9.snap index 4688a1774..7cc92559f 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_9.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__error_recovery__schema_stmt_recovery_9.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/error_recovery.rs +assertion_line: 218 expression: "crate::tests::parsing_module_string(r#\"schema A:\n[]: []\"#)" --- Module { @@ -65,16 +66,6 @@ Module { end_line: 2, end_column: 6, }, - type_annotation: Some( - Node { - node: "[]", - filename: "", - line: 2, - column: 4, - end_line: 2, - end_column: 6, - }, - ), ty: Some( Node { node: List( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_0.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_0.snap index 39e4e5a6e..0d919f9bc 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_0.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_0.snap @@ -1,12 +1,12 @@ --- source: parser/src/tests/expr.rs +assertion_line: 79 expression: "crate::tests::parsing_expr_string(r####\"lambda {}\"####)" --- Node { node: Lambda( LambdaExpr { args: None, - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_1.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_1.snap index a560a0138..f6415f382 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_1.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_1.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/expr.rs +assertion_line: 80 expression: "crate::tests::parsing_expr_string(r####\"lambda x {}\"####)" --- Node { @@ -34,9 +35,6 @@ Node { defaults: [ None, ], - type_annotation_list: [ - None, - ], ty_list: [ None, ], @@ -48,7 +46,6 @@ Node { end_column: 8, }, ), - return_type_str: None, body: [], return_ty: None, }, diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_2.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_2.snap index 5a8575f24..0364c43ef 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_2.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_2.snap @@ -1,5 +1,6 @@ --- source: parser/src/tests/expr.rs +assertion_line: 81 expression: "crate::tests::parsing_expr_string(r####\"lambda x: int -> int {x}\"####)" --- Node { @@ -34,18 +35,6 @@ Node { defaults: [ None, ], - type_annotation_list: [ - Some( - Node { - node: "int", - filename: "", - line: 1, - column: 10, - end_line: 1, - end_column: 13, - }, - ), - ], ty_list: [ Some( Node { @@ -68,9 +57,6 @@ Node { end_column: 13, }, ), - return_type_str: Some( - "int", - ), body: [ Node { node: Expr( diff --git a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_3.snap b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_3.snap index cec3abf08..db438a698 100644 --- a/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_3.snap +++ b/kclvm/parser/src/tests/snapshots/kclvm_parser__tests__expr__lambda_expr_3.snap @@ -1,12 +1,12 @@ --- source: parser/src/tests/expr.rs +assertion_line: 82 expression: "crate::tests::parsing_expr_string(r####\"lambda {\n if True:\n _a = 1\n else:\n _a = 2\n _a\n}\"####)" --- Node { node: Lambda( LambdaExpr { args: None, - return_type_str: None, body: [ Node { node: If( @@ -53,7 +53,6 @@ Node { end_line: 3, end_column: 14, }, - type_annotation: None, ty: None, }, ), @@ -118,7 +117,6 @@ Node { end_line: 5, end_column: 14, }, - type_annotation: None, ty: None, }, ), 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 ee680893d..841283bd6 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 4 expression: "crate::tests::parsing_file_string(\"testdata/assert-02.k\")" --- -{"filename":"assert-02.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"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,"column":0,"end_line":1,"end_column":11},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-02.k","line":2,"column":7,"end_line":2,"end_column":8},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":0,"end_line":2,"end_column":13},{"node":{"Assign":{"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":{"node":{"StringLit":{"is_long_string":false,"raw_value":"\"good case\"","value":"good case"}},"filename":"assert-02.k","line":3,"column":5,"end_line":3,"end_column":16},"type_annotation":null,"ty":null}},"filename":"assert-02.k","line":3,"column":0,"end_line":3,"end_column":16},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":[{"node":{"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}]}},"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,"column":0,"end_line":4,"end_column":24}],"comments":[]} +{"filename":"assert-02.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"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,"column":0,"end_line":1,"end_column":11},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-02.k","line":2,"column":7,"end_line":2,"end_column":8},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":0,"end_line":2,"end_column":13},{"node":{"Assign":{"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":{"node":{"StringLit":{"is_long_string":false,"raw_value":"\"good case\"","value":"good case"}},"filename":"assert-02.k","line":3,"column":5,"end_line":3,"end_column":16},"ty":null}},"filename":"assert-02.k","line":3,"column":0,"end_line":3,"end_column":16},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":[{"node":{"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}]}},"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,"column":0,"end_line":4,"end_column":24}],"comments":[]} 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 f91d78efb..91b7acfec 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 5 expression: "crate::tests::parsing_file_string(\"testdata/assert-03.k\")" --- -{"filename":"assert-03.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"If":{"body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-03.k","line":2,"column":11,"end_line":2,"end_column":15},"if_cond":null,"msg":{"node":{"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}}},"filename":"assert-03.k","line":2,"column":4,"end_line":2,"end_column":32},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-03.k","line":3,"column":11,"end_line":3,"end_column":12},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-03.k","line":3,"column":16,"end_line":3,"end_column":17}]}},"filename":"assert-03.k","line":3,"column":11,"end_line":3,"end_column":17},"if_cond":null,"msg":{"node":{"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":{"Assign":{"targets":[{"node":{"names":[{"node":"_x","filename":"assert-03.k","line":4,"column":4,"end_line":4,"end_column":6}],"pkgpath":"","ctx":"Store"},"filename":"assert-03.k","line":4,"column":4,"end_line":4,"end_column":6}],"value":{"node":{"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},"type_annotation":null,"ty":null}},"filename":"assert-03.k","line":4,"column":4,"end_line":4,"end_column":20},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"_x","filename":"assert-03.k","line":5,"column":11,"end_line":5,"end_column":13}],"pkgpath":"","ctx":"Load"}},"filename":"assert-03.k","line":5,"column":11,"end_line":5,"end_column":13},"ops":["Eq"],"comparators":[{"node":{"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},"if_cond":null,"msg":null}},"filename":"assert-03.k","line":5,"column":4,"end_line":5,"end_column":28}],"cond":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-03.k","line":1,"column":3,"end_line":1,"end_column":7},"orelse":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"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":7,"column":4,"end_line":7,"end_column":16}]}},"filename":"assert-03.k","line":1,"column":0,"end_line":8,"end_column":1}],"comments":[]} +{"filename":"assert-03.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"If":{"body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-03.k","line":2,"column":11,"end_line":2,"end_column":15},"if_cond":null,"msg":{"node":{"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}}},"filename":"assert-03.k","line":2,"column":4,"end_line":2,"end_column":32},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-03.k","line":3,"column":11,"end_line":3,"end_column":12},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-03.k","line":3,"column":16,"end_line":3,"end_column":17}]}},"filename":"assert-03.k","line":3,"column":11,"end_line":3,"end_column":17},"if_cond":null,"msg":{"node":{"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":{"Assign":{"targets":[{"node":{"names":[{"node":"_x","filename":"assert-03.k","line":4,"column":4,"end_line":4,"end_column":6}],"pkgpath":"","ctx":"Store"},"filename":"assert-03.k","line":4,"column":4,"end_line":4,"end_column":6}],"value":{"node":{"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},"ty":null}},"filename":"assert-03.k","line":4,"column":4,"end_line":4,"end_column":20},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"_x","filename":"assert-03.k","line":5,"column":11,"end_line":5,"end_column":13}],"pkgpath":"","ctx":"Load"}},"filename":"assert-03.k","line":5,"column":11,"end_line":5,"end_column":13},"ops":["Eq"],"comparators":[{"node":{"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},"if_cond":null,"msg":null}},"filename":"assert-03.k","line":5,"column":4,"end_line":5,"end_column":28}],"cond":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-03.k","line":1,"column":3,"end_line":1,"end_column":7},"orelse":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"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":7,"column":4,"end_line":7,"end_column":16}]}},"filename":"assert-03.k","line":1,"column":0,"end_line":8,"end_column":1}],"comments":[]} 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 06981d5dc..e3f2e9054 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 6 expression: "crate::tests::parsing_file_string(\"testdata/assert-if-0.k\")" --- -{"filename":"assert-if-0.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"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,"column":0,"end_line":1,"end_column":11},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-0.k","line":2,"column":7,"end_line":2,"end_column":8},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"NameConstantLit":{"value":"True"}},"filename":"assert-if-0.k","line":2,"column":17,"end_line":2,"end_column":21},"msg":null}},"filename":"assert-if-0.k","line":2,"column":0,"end_line":2,"end_column":21},{"node":{"Assign":{"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":{"node":{"StringLit":{"is_long_string":false,"raw_value":"\"good case\"","value":"good case"}},"filename":"assert-if-0.k","line":3,"column":5,"end_line":3,"end_column":16},"type_annotation":null,"ty":null}},"filename":"assert-if-0.k","line":3,"column":0,"end_line":3,"end_column":16},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":{"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}]}},"filename":"assert-if-0.k","line":4,"column":7,"end_line":4,"end_column":24},"if_cond":{"node":{"Identifier":{"names":[{"node":"_x","filename":"assert-if-0.k","line":4,"column":28,"end_line":4,"end_column":30}],"pkgpath":"","ctx":"Load"}},"filename":"assert-if-0.k","line":4,"column":28,"end_line":4,"end_column":30},"msg":{"node":{"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","line":4,"column":0,"end_line":4,"end_column":59}],"comments":[]} +{"filename":"assert-if-0.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"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,"column":0,"end_line":1,"end_column":11},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-0.k","line":2,"column":7,"end_line":2,"end_column":8},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"NameConstantLit":{"value":"True"}},"filename":"assert-if-0.k","line":2,"column":17,"end_line":2,"end_column":21},"msg":null}},"filename":"assert-if-0.k","line":2,"column":0,"end_line":2,"end_column":21},{"node":{"Assign":{"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":{"node":{"StringLit":{"is_long_string":false,"raw_value":"\"good case\"","value":"good case"}},"filename":"assert-if-0.k","line":3,"column":5,"end_line":3,"end_column":16},"ty":null}},"filename":"assert-if-0.k","line":3,"column":0,"end_line":3,"end_column":16},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":{"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}]}},"filename":"assert-if-0.k","line":4,"column":7,"end_line":4,"end_column":24},"if_cond":{"node":{"Identifier":{"names":[{"node":"_x","filename":"assert-if-0.k","line":4,"column":28,"end_line":4,"end_column":30}],"pkgpath":"","ctx":"Load"}},"filename":"assert-if-0.k","line":4,"column":28,"end_line":4,"end_column":30},"msg":{"node":{"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","line":4,"column":0,"end_line":4,"end_column":59}],"comments":[]} 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 1f49f653a..84ea08c69 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 7 expression: "crate::tests::parsing_file_string(\"testdata/assert-if-1.k\")" --- -{"filename":"assert-if-1.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-if-1.k","line":1,"column":7,"end_line":1,"end_column":11},"if_cond":{"node":{"NameConstantLit":{"value":"False"}},"filename":"assert-if-1.k","line":1,"column":15,"end_line":1,"end_column":20},"msg":null}},"filename":"assert-if-1.k","line":1,"column":0,"end_line":1,"end_column":20},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-1.k","line":2,"column":7,"end_line":2,"end_column":8},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"NameConstantLit":{"value":"False"}},"filename":"assert-if-1.k","line":2,"column":17,"end_line":2,"end_column":22},"msg":null}},"filename":"assert-if-1.k","line":2,"column":0,"end_line":2,"end_column":22},{"node":{"Assign":{"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":{"node":{"StringLit":{"is_long_string":false,"raw_value":"\"good case\"","value":"good case"}},"filename":"assert-if-1.k","line":3,"column":5,"end_line":3,"end_column":16},"type_annotation":null,"ty":null}},"filename":"assert-if-1.k","line":3,"column":0,"end_line":3,"end_column":16},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":[{"node":{"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":7,"end_line":4,"end_column":24},"if_cond":{"node":{"Unary":{"op":"Not","operand":{"node":{"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":{"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","line":4,"column":0,"end_line":4,"end_column":63}],"comments":[]} +{"filename":"assert-if-1.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-if-1.k","line":1,"column":7,"end_line":1,"end_column":11},"if_cond":{"node":{"NameConstantLit":{"value":"False"}},"filename":"assert-if-1.k","line":1,"column":15,"end_line":1,"end_column":20},"msg":null}},"filename":"assert-if-1.k","line":1,"column":0,"end_line":1,"end_column":20},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-1.k","line":2,"column":7,"end_line":2,"end_column":8},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"NameConstantLit":{"value":"False"}},"filename":"assert-if-1.k","line":2,"column":17,"end_line":2,"end_column":22},"msg":null}},"filename":"assert-if-1.k","line":2,"column":0,"end_line":2,"end_column":22},{"node":{"Assign":{"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":{"node":{"StringLit":{"is_long_string":false,"raw_value":"\"good case\"","value":"good case"}},"filename":"assert-if-1.k","line":3,"column":5,"end_line":3,"end_column":16},"ty":null}},"filename":"assert-if-1.k","line":3,"column":0,"end_line":3,"end_column":16},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"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":[{"node":{"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":7,"end_line":4,"end_column":24},"if_cond":{"node":{"Unary":{"op":"Not","operand":{"node":{"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":{"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","line":4,"column":0,"end_line":4,"end_column":63}],"comments":[]} 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 eb9414786..c1394a9cb 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 8 expression: "crate::tests::parsing_file_string(\"testdata/assert-if-2.k\")" --- -{"filename":"assert-if-2.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-if-2.k","line":2,"column":11,"end_line":2,"end_column":15},"if_cond":{"node":{"NameConstantLit":{"value":"False"}},"filename":"assert-if-2.k","line":2,"column":19,"end_line":2,"end_column":24},"msg":null}},"filename":"assert-if-2.k","line":2,"column":4,"end_line":2,"end_column":24},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-2.k","line":3,"column":11,"end_line":3,"end_column":12},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-2.k","line":3,"column":16,"end_line":3,"end_column":17}]}},"filename":"assert-if-2.k","line":3,"column":11,"end_line":3,"end_column":17},"if_cond":{"node":{"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":{"Assign":{"targets":[{"node":{"names":[{"node":"_x","filename":"assert-if-2.k","line":4,"column":4,"end_line":4,"end_column":6}],"pkgpath":"","ctx":"Store"},"filename":"assert-if-2.k","line":4,"column":4,"end_line":4,"end_column":6}],"value":{"node":{"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},"type_annotation":null,"ty":null}},"filename":"assert-if-2.k","line":4,"column":4,"end_line":4,"end_column":20},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"_x","filename":"assert-if-2.k","line":5,"column":11,"end_line":5,"end_column":13}],"pkgpath":"","ctx":"Load"}},"filename":"assert-if-2.k","line":5,"column":11,"end_line":5,"end_column":13},"ops":["Eq"],"comparators":[{"node":{"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":{"Unary":{"op":"Not","operand":{"node":{"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":36,"end_line":5,"end_column":38}}},"filename":"assert-if-2.k","line":5,"column":32,"end_line":5,"end_column":38},"msg":{"node":{"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,"column":0,"end_line":7,"end_column":0},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[]}},"filename":"assert-if-2.k","line":7,"column":12,"end_line":7,"end_column":14}}},"filename":"assert-if-2.k","line":7,"column":7,"end_line":7,"end_column":14},"type_annotation":null,"ty":null}},"filename":"assert-if-2.k","line":7,"column":0,"end_line":7,"end_column":14}],"comments":[]} +{"filename":"assert-if-2.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"Assert":{"test":{"node":{"NameConstantLit":{"value":"True"}},"filename":"assert-if-2.k","line":2,"column":11,"end_line":2,"end_column":15},"if_cond":{"node":{"NameConstantLit":{"value":"False"}},"filename":"assert-if-2.k","line":2,"column":19,"end_line":2,"end_column":24},"msg":null}},"filename":"assert-if-2.k","line":2,"column":4,"end_line":2,"end_column":24},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-2.k","line":3,"column":11,"end_line":3,"end_column":12},"ops":["Eq"],"comparators":[{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assert-if-2.k","line":3,"column":16,"end_line":3,"end_column":17}]}},"filename":"assert-if-2.k","line":3,"column":11,"end_line":3,"end_column":17},"if_cond":{"node":{"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":{"Assign":{"targets":[{"node":{"names":[{"node":"_x","filename":"assert-if-2.k","line":4,"column":4,"end_line":4,"end_column":6}],"pkgpath":"","ctx":"Store"},"filename":"assert-if-2.k","line":4,"column":4,"end_line":4,"end_column":6}],"value":{"node":{"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},"ty":null}},"filename":"assert-if-2.k","line":4,"column":4,"end_line":4,"end_column":20},{"node":{"Assert":{"test":{"node":{"Compare":{"left":{"node":{"Identifier":{"names":[{"node":"_x","filename":"assert-if-2.k","line":5,"column":11,"end_line":5,"end_column":13}],"pkgpath":"","ctx":"Load"}},"filename":"assert-if-2.k","line":5,"column":11,"end_line":5,"end_column":13},"ops":["Eq"],"comparators":[{"node":{"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":{"Unary":{"op":"Not","operand":{"node":{"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":36,"end_line":5,"end_column":38}}},"filename":"assert-if-2.k","line":5,"column":32,"end_line":5,"end_column":38},"msg":{"node":{"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,"column":0,"end_line":7,"end_column":0},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[]}},"filename":"assert-if-2.k","line":7,"column":12,"end_line":7,"end_column":14}}},"filename":"assert-if-2.k","line":7,"column":7,"end_line":7,"end_column":14},"ty":null}},"filename":"assert-if-2.k","line":7,"column":0,"end_line":7,"end_column":14}],"comments":[]} 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 e1b261600..86eebd97d 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 9 expression: "crate::tests::parsing_file_string(\"testdata/assign-01.k\")" --- -{"filename":"assign-01.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assign-01.k","line":1,"column":2,"end_line":1,"end_column":3},"type_annotation":null,"ty":null}},"filename":"assign-01.k","line":1,"column":0,"end_line":1,"end_column":3},{"node":{"Assign":{"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":{"node":{"Binary":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assign-01.k","line":2,"column":4,"end_line":2,"end_column":5},"op":{"Bin":"Add"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"assign-01.k","line":2,"column":8,"end_line":2,"end_column":9}}},"filename":"assign-01.k","line":2,"column":4,"end_line":2,"end_column":9},"type_annotation":null,"ty":null}},"filename":"assign-01.k","line":2,"column":0,"end_line":2,"end_column":9},{"node":{"Assign":{"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":{"Binary":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"assign-01.k","line":3,"column":4,"end_line":3,"end_column":5},"op":{"Bin":"Add"},"right":{"node":{"Binary":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"assign-01.k","line":3,"column":8,"end_line":3,"end_column":9},"op":{"Bin":"Mul"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":3}}},"filename":"assign-01.k","line":3,"column":10,"end_line":3,"end_column":11}}},"filename":"assign-01.k","line":3,"column":8,"end_line":3,"end_column":11}}},"filename":"assign-01.k","line":3,"column":4,"end_line":3,"end_column":11},"type_annotation":null,"ty":null}},"filename":"assign-01.k","line":3,"column":0,"end_line":3,"end_column":11}],"comments":[]} +{"filename":"assign-01.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assign-01.k","line":1,"column":2,"end_line":1,"end_column":3},"ty":null}},"filename":"assign-01.k","line":1,"column":0,"end_line":1,"end_column":3},{"node":{"Assign":{"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":{"node":{"Binary":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"assign-01.k","line":2,"column":4,"end_line":2,"end_column":5},"op":{"Bin":"Add"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"assign-01.k","line":2,"column":8,"end_line":2,"end_column":9}}},"filename":"assign-01.k","line":2,"column":4,"end_line":2,"end_column":9},"ty":null}},"filename":"assign-01.k","line":2,"column":0,"end_line":2,"end_column":9},{"node":{"Assign":{"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":{"Binary":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"assign-01.k","line":3,"column":4,"end_line":3,"end_column":5},"op":{"Bin":"Add"},"right":{"node":{"Binary":{"left":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"assign-01.k","line":3,"column":8,"end_line":3,"end_column":9},"op":{"Bin":"Mul"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":3}}},"filename":"assign-01.k","line":3,"column":10,"end_line":3,"end_column":11}}},"filename":"assign-01.k","line":3,"column":8,"end_line":3,"end_column":11}}},"filename":"assign-01.k","line":3,"column":4,"end_line":3,"end_column":11},"ty":null}},"filename":"assign-01.k","line":3,"column":0,"end_line":3,"end_column":11}],"comments":[]} 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 e24819cc8..76962bf05 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 10 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-01.k\")" --- -{"filename":"config_expr-01.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"Config":{"items":[]}},"filename":"config_expr-01.k","line":1,"column":9,"end_line":2,"end_column":1},"type_annotation":null,"ty":null}},"filename":"config_expr-01.k","line":1,"column":0,"end_line":2,"end_column":1}],"comments":[]} +{"filename":"config_expr-01.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"Config":{"items":[]}},"filename":"config_expr-01.k","line":1,"column":9,"end_line":2,"end_column":1},"ty":null}},"filename":"config_expr-01.k","line":1,"column":0,"end_line":2,"end_column":1}],"comments":[]} 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 bd84b7546..5c560d1fc 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 11 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-02.k\")" --- -{"filename":"config_expr-02.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"Config":{"items":[{"node":{"key":{"node":{"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":2,"column":4,"end_line":2,"end_column":6},"value":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":111}}},"filename":"config_expr-02.k","line":2,"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":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":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},"type_annotation":null,"ty":null}},"filename":"config_expr-02.k","line":1,"column":0,"end_line":4,"end_column":1}],"comments":[]} +{"filename":"config_expr-02.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"Config":{"items":[{"node":{"key":{"node":{"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":2,"column":4,"end_line":2,"end_column":6},"value":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":111}}},"filename":"config_expr-02.k","line":2,"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":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":0,"end_line":4,"end_column":1}],"comments":[]} 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 0b1d278c5..d9e5b1cad 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 12 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-03.k\")" --- -{"filename":"config_expr-03.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"Config":{"items":[{"node":{"key":{"node":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"env","filename":"config_expr-03.k","line":5,"column":8,"end_line":5,"end_column":11}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-03.k","line":5,"column":8,"end_line":5,"end_column":11},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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":{"Identifier":{"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":{"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},"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":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":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":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"env","filename":"config_expr-03.k","line":10,"column":8,"end_line":10,"end_column":11}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-03.k","line":10,"column":8,"end_line":10,"end_column":11},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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":{"Identifier":{"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":{"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},"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":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":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},"type_annotation":null,"ty":null}},"filename":"config_expr-03.k","line":3,"column":0,"end_line":14,"end_column":1}],"comments":[{"node":{"text":"# test/grammar/attr_operator/config_inside/insert/dict_0/main.k"},"filename":"config_expr-03.k","line":1,"column":0,"end_line":1,"end_column":63}]} +{"filename":"config_expr-03.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"Config":{"items":[{"node":{"key":{"node":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"env","filename":"config_expr-03.k","line":5,"column":8,"end_line":5,"end_column":11}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-03.k","line":5,"column":8,"end_line":5,"end_column":11},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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":{"Identifier":{"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":{"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},"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":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":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":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"env","filename":"config_expr-03.k","line":10,"column":8,"end_line":10,"end_column":11}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-03.k","line":10,"column":8,"end_line":10,"end_column":11},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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":{"Identifier":{"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":{"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},"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":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":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":0,"end_line":14,"end_column":1}],"comments":[{"node":{"text":"# test/grammar/attr_operator/config_inside/insert/dict_0/main.k"},"filename":"config_expr-03.k","line":1,"column":0,"end_line":1,"end_column":63}]} 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 b9c96754a..ec599ac51 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 13 expression: "crate::tests::parsing_file_string(\"testdata/config_expr-04.k\")" --- -{"filename":"config_expr-04.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"SchemaAttr":{"doc":"","name":{"node":"name","filename":"config_expr-04.k","line":4,"column":4,"end_line":4,"end_column":8},"type_str":{"node":"str","filename":"config_expr-04.k","line":4,"column":10,"end_line":4,"end_column":13},"op":null,"value":null,"is_optional":false,"decorators":[],"ty":{"node":{"Basic":"Str"},"filename":"config_expr-04.k","line":4,"column":10,"end_line":4,"end_column":13}}},"filename":"config_expr-04.k","line":4,"column":4,"end_line":4,"end_column":13},{"node":{"SchemaAttr":{"doc":"","name":{"node":"value","filename":"config_expr-04.k","line":5,"column":4,"end_line":5,"end_column":9},"type_str":{"node":"str","filename":"config_expr-04.k","line":5,"column":11,"end_line":5,"end_column":14},"op":null,"value":null,"is_optional":false,"decorators":[],"ty":{"node":{"Basic":"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":3,"column":0,"end_line":7,"end_column":0},{"node":{"Schema":{"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":{"SchemaAttr":{"doc":"","name":{"node":"env","filename":"config_expr-04.k","line":8,"column":4,"end_line":8,"end_column":7},"type_str":{"node":"[Env]","filename":"config_expr-04.k","line":8,"column":9,"end_line":8,"end_column":14},"op":null,"value":null,"is_optional":false,"decorators":[],"ty":{"node":{"List":{"inner_type":{"node":{"Named":{"names":[{"node":"Env","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":10,"end_line":8,"end_column":13}}},"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,"column":0,"end_line":10,"end_column":0},{"node":{"Schema":{"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":{"SchemaAttr":{"doc":"","name":{"node":"main","filename":"config_expr-04.k","line":11,"column":4,"end_line":11,"end_column":8},"type_str":{"node":"Main","filename":"config_expr-04.k","line":11,"column":10,"end_line":11,"end_column":14},"op":null,"value":null,"is_optional":false,"decorators":[],"ty":{"node":{"Named":{"names":[{"node":"Main","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":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,"column":0,"end_line":13,"end_column":0},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"env","filename":"config_expr-04.k","line":14,"column":4,"end_line":14,"end_column":7}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-04.k","line":14,"column":4,"end_line":14,"end_column":7},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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":{"Identifier":{"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":{"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":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}}},"filename":"config_expr-04.k","line":13,"column":8,"end_line":17,"end_column":1},"type_annotation":null,"ty":null}},"filename":"config_expr-04.k","line":13,"column":0,"end_line":17,"end_column":1},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"main","filename":"config_expr-04.k","line":20,"column":4,"end_line":20,"end_column":8}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-04.k","line":20,"column":4,"end_line":20,"end_column":8},"value":{"node":{"Identifier":{"names":[{"node":"_main","filename":"config_expr-04.k","line":20,"column":10,"end_line":20,"end_column":15}],"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":{"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":{"Schema":{"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":{"Config":{"items":[{"node":{"key":{"node":{"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},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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},{"node":{"key":{"node":{"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":{"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":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},"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":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}}},"filename":"config_expr-04.k","line":19,"column":9,"end_line":26,"end_column":1},"type_annotation":null,"ty":null}},"filename":"config_expr-04.k","line":19,"column":0,"end_line":26,"end_column":1}],"comments":[{"node":{"text":"# test/grammar/attr_operator/config_inside/insert/schema_0/main.k"},"filename":"config_expr-04.k","line":1,"column":0,"end_line":1,"end_column":65}]} +{"filename":"config_expr-04.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"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":{"Basic":"Str"},"filename":"config_expr-04.k","line":4,"column":10,"end_line":4,"end_column":13}}},"filename":"config_expr-04.k","line":4,"column":4,"end_line":4,"end_column":13},{"node":{"SchemaAttr":{"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":{"Basic":"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":3,"column":0,"end_line":7,"end_column":0},{"node":{"Schema":{"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":{"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":{"List":{"inner_type":{"node":{"Named":{"names":[{"node":"Env","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":10,"end_line":8,"end_column":13}}},"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,"column":0,"end_line":10,"end_column":0},{"node":{"Schema":{"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":{"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":{"Named":{"names":[{"node":"Main","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":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,"column":0,"end_line":13,"end_column":0},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"env","filename":"config_expr-04.k","line":14,"column":4,"end_line":14,"end_column":7}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-04.k","line":14,"column":4,"end_line":14,"end_column":7},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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":{"Identifier":{"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":{"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":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}}},"filename":"config_expr-04.k","line":13,"column":8,"end_line":17,"end_column":1},"ty":null}},"filename":"config_expr-04.k","line":13,"column":0,"end_line":17,"end_column":1},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"names":[{"node":"main","filename":"config_expr-04.k","line":20,"column":4,"end_line":20,"end_column":8}],"pkgpath":"","ctx":"Load"}},"filename":"config_expr-04.k","line":20,"column":4,"end_line":20,"end_column":8},"value":{"node":{"Identifier":{"names":[{"node":"_main","filename":"config_expr-04.k","line":20,"column":10,"end_line":20,"end_column":15}],"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":{"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":{"Schema":{"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":{"Config":{"items":[{"node":{"key":{"node":{"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},"value":{"node":{"List":{"elts":[{"node":{"Config":{"items":[{"node":{"key":{"node":{"Identifier":{"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":{"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},{"node":{"key":{"node":{"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":{"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":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},"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":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}}},"filename":"config_expr-04.k","line":19,"column":9,"end_line":26,"end_column":1},"ty":null}},"filename":"config_expr-04.k","line":19,"column":0,"end_line":26,"end_column":1}],"comments":[{"node":{"text":"# test/grammar/attr_operator/config_inside/insert/schema_0/main.k"},"filename":"config_expr-04.k","line":1,"column":0,"end_line":1,"end_column":65}]} 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 5e713f5e1..56997a478 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 19 expression: "crate::tests::parsing_file_string(\"testdata/hello_win.k\")" --- -{"filename":"hello_win.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"SchemaAttr":{"doc":"","name":{"node":"name","filename":"hello_win.k","line":3,"column":4,"end_line":3,"end_column":8},"type_str":{"node":"str","filename":"hello_win.k","line":3,"column":10,"end_line":3,"end_column":13},"op":{"Aug":"Assign"},"value":{"node":{"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":{"Basic":"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,"column":0,"end_line":5,"end_column":0},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[]}},"filename":"hello_win.k","line":5,"column":12,"end_line":5,"end_column":14}}},"filename":"hello_win.k","line":5,"column":5,"end_line":5,"end_column":14},"type_annotation":null,"ty":null}},"filename":"hello_win.k","line":5,"column":0,"end_line":5,"end_column":14}],"comments":[]} +{"filename":"hello_win.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Schema":{"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":{"SchemaAttr":{"doc":"","name":{"node":"name","filename":"hello_win.k","line":3,"column":4,"end_line":3,"end_column":8},"op":{"Aug":"Assign"},"value":{"node":{"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":{"Basic":"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,"column":0,"end_line":5,"end_column":0},{"node":{"Assign":{"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":{"Schema":{"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":{"Config":{"items":[]}},"filename":"hello_win.k","line":5,"column":12,"end_line":5,"end_column":14}}},"filename":"hello_win.k","line":5,"column":5,"end_line":5,"end_column":14},"ty":null}},"filename":"hello_win.k","line":5,"column":0,"end_line":5,"end_column":14}],"comments":[]} 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 863993b6d..d448725c1 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 15 expression: "crate::tests::parsing_file_string(\"testdata/if-01.k\")" --- -{"filename":"if-01.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"if-01.k","line":1,"column":4,"end_line":1,"end_column":5},"type_annotation":null,"ty":null}},"filename":"if-01.k","line":1,"column":0,"end_line":1,"end_column":5},{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"if-01.k","line":4,"column":10,"end_line":4,"end_column":11},"type_annotation":null,"ty":null}},"filename":"if-01.k","line":4,"column":4,"end_line":4,"end_column":11}],"cond":{"node":{"Identifier":{"names":[{"node":"a","filename":"if-01.k","line":3,"column":3,"end_line":3,"end_column":4}],"pkgpath":"","ctx":"Load"}},"filename":"if-01.k","line":3,"column":3,"end_line":3,"end_column":4},"orelse":[]}},"filename":"if-01.k","line":3,"column":0,"end_line":4,"end_column":12}],"comments":[]} +{"filename":"if-01.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"if-01.k","line":1,"column":4,"end_line":1,"end_column":5},"ty":null}},"filename":"if-01.k","line":1,"column":0,"end_line":1,"end_column":5},{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"if-01.k","line":4,"column":10,"end_line":4,"end_column":11},"ty":null}},"filename":"if-01.k","line":4,"column":4,"end_line":4,"end_column":11}],"cond":{"node":{"Identifier":{"names":[{"node":"a","filename":"if-01.k","line":3,"column":3,"end_line":3,"end_column":4}],"pkgpath":"","ctx":"Load"}},"filename":"if-01.k","line":3,"column":3,"end_line":3,"end_column":4},"orelse":[]}},"filename":"if-01.k","line":3,"column":0,"end_line":4,"end_column":12}],"comments":[]} 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 3ad908eef..3c8c8a177 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 16 expression: "crate::tests::parsing_file_string(\"testdata/if-02.k\")" --- -{"filename":"if-02.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"if-02.k","line":1,"column":4,"end_line":1,"end_column":5},"type_annotation":null,"ty":null}},"filename":"if-02.k","line":1,"column":0,"end_line":1,"end_column":5},{"node":{"If":{"body":[{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":2}}},"filename":"if-02.k","line":4,"column":10,"end_line":4,"end_column":11},"type_annotation":null,"ty":null}},"filename":"if-02.k","line":4,"column":4,"end_line":4,"end_column":11}],"cond":{"node":{"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":{"If":{"body":[{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":3}}},"filename":"if-02.k","line":6,"column":10,"end_line":6,"end_column":11},"type_annotation":null,"ty":null}},"filename":"if-02.k","line":6,"column":4,"end_line":6,"end_column":11}],"cond":{"node":{"Binary":{"left":{"node":{"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":{"Bin":"Add"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":10}}},"filename":"if-02.k","line":5,"column":9,"end_line":5,"end_column":11}}},"filename":"if-02.k","line":5,"column":5,"end_line":5,"end_column":11},"orelse":[{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":4}}},"filename":"if-02.k","line":8,"column":10,"end_line":8,"end_column":11},"type_annotation":null,"ty":null}},"filename":"if-02.k","line":8,"column":4,"end_line":8,"end_column":11}],"cond":{"node":{"Binary":{"left":{"node":{"Identifier":{"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":{"Bin":"Add"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":100}}},"filename":"if-02.k","line":7,"column":9,"end_line":7,"end_column":12}}},"filename":"if-02.k","line":7,"column":5,"end_line":7,"end_column":12},"orelse":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":5}}},"filename":"if-02.k","line":10,"column":10,"end_line":10,"end_column":11},"type_annotation":null,"ty":null}},"filename":"if-02.k","line":10,"column":4,"end_line":10,"end_column":11},{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":6}}},"filename":"if-02.k","line":11,"column":10,"end_line":11,"end_column":11},"type_annotation":null,"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":3,"column":0,"end_line":11,"end_column":12}],"comments":[]} +{"filename":"if-02.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"Assign":{"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":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"if-02.k","line":1,"column":4,"end_line":1,"end_column":5},"ty":null}},"filename":"if-02.k","line":1,"column":0,"end_line":1,"end_column":5},{"node":{"If":{"body":[{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":{"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":{"If":{"body":[{"node":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":3}}},"filename":"if-02.k","line":6,"column":10,"end_line":6,"end_column":11},"ty":null}},"filename":"if-02.k","line":6,"column":4,"end_line":6,"end_column":11}],"cond":{"node":{"Binary":{"left":{"node":{"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":{"Bin":"Add"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":10}}},"filename":"if-02.k","line":5,"column":9,"end_line":5,"end_column":11}}},"filename":"if-02.k","line":5,"column":5,"end_line":5,"end_column":11},"orelse":[{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":4}}},"filename":"if-02.k","line":8,"column":10,"end_line":8,"end_column":11},"ty":null}},"filename":"if-02.k","line":8,"column":4,"end_line":8,"end_column":11}],"cond":{"node":{"Binary":{"left":{"node":{"Identifier":{"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":{"Bin":"Add"},"right":{"node":{"NumberLit":{"binary_suffix":null,"value":{"Int":100}}},"filename":"if-02.k","line":7,"column":9,"end_line":7,"end_column":12}}},"filename":"if-02.k","line":7,"column":5,"end_line":7,"end_column":12},"orelse":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":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},{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":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":3,"column":0,"end_line":11,"end_column":12}],"comments":[]} 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 8f6967c03..61202ff59 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,5 +1,6 @@ --- source: parser/src/tests/file.rs +assertion_line: 17 expression: "crate::tests::parsing_file_string(\"testdata/if-03.k\")" --- -{"filename":"if-03.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"if-03.k","line":1,"column":13,"end_line":1,"end_column":14},"type_annotation":null,"ty":null}},"filename":"if-03.k","line":1,"column":9,"end_line":1,"end_column":14}],"cond":{"node":{"NameConstantLit":{"value":"True"}},"filename":"if-03.k","line":1,"column":3,"end_line":1,"end_column":7},"orelse":[]}},"filename":"if-03.k","line":1,"column":0,"end_line":1,"end_column":15}],"comments":[]} +{"filename":"if-03.k","pkg":"__main__","doc":null,"name":"__main__","body":[{"node":{"If":{"body":[{"node":{"Assign":{"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":{"NumberLit":{"binary_suffix":null,"value":{"Int":1}}},"filename":"if-03.k","line":1,"column":13,"end_line":1,"end_column":14},"ty":null}},"filename":"if-03.k","line":1,"column":9,"end_line":1,"end_column":14}],"cond":{"node":{"NameConstantLit":{"value":"True"}},"filename":"if-03.k","line":1,"column":3,"end_line":1,"end_column":7},"orelse":[]}},"filename":"if-03.k","line":1,"column":0,"end_line":1,"end_column":15}],"comments":[]} diff --git a/kclvm/sema/src/resolver/global.rs b/kclvm/sema/src/resolver/global.rs index 9777278f8..f0921f674 100644 --- a/kclvm/sema/src/resolver/global.rs +++ b/kclvm/sema/src/resolver/global.rs @@ -533,12 +533,12 @@ impl<'ctx> Resolver<'ctx> { } } let key_ty = self.parse_ty_str_with_scope( - &index_signature.node.key_type.node, - index_signature.node.key_type.get_span_pos(), + &index_signature.node.key_ty.node.to_string(), + index_signature.node.key_ty.get_span_pos(), ); let val_ty = self.parse_ty_with_scope( Some(&index_signature.node.value_ty), - index_signature.node.value_type.get_span_pos(), + index_signature.node.value_ty.get_span_pos(), ); if !self .ctx diff --git a/kclvm/sema/src/resolver/mod.rs b/kclvm/sema/src/resolver/mod.rs index 3da10e5ad..cc61cae17 100644 --- a/kclvm/sema/src/resolver/mod.rs +++ b/kclvm/sema/src/resolver/mod.rs @@ -13,7 +13,7 @@ mod schema; pub mod scope; pub(crate) mod ty; mod ty_alias; -mod type_erasure; +mod ty_erasure; mod var; #[cfg(test)] @@ -27,8 +27,8 @@ use std::{cell::RefCell, rc::Rc}; use crate::lint::{CombinedLintPass, Linter}; use crate::pre_process::pre_process_program; use crate::resolver::scope::ScopeObject; -use crate::resolver::ty_alias::process_program_type_alias; -use crate::resolver::type_erasure::type_erasure; +use crate::resolver::ty_alias::type_alias_pass; +use crate::resolver::ty_erasure::type_func_erasure_pass; use crate::ty::{TypeContext, TypeRef}; use crate::{resolver::scope::Scope, ty::SchemaType}; use kclvm_ast::ast::AstIndex; @@ -150,7 +150,7 @@ pub struct Options { pub lint_check: bool, pub resolve_val: bool, pub merge_program: bool, - pub type_alise: bool, + pub type_erasure: bool, } impl Default for Options { @@ -159,7 +159,7 @@ impl Default for Options { lint_check: true, resolve_val: false, merge_program: true, - type_alise: true, + type_erasure: true, } } } @@ -197,11 +197,12 @@ pub fn resolve_program_with_opts( } } - if opts.type_alise { + if opts.type_erasure { + // Erase types with their type alias let type_alias_mapping = resolver.ctx.type_alias_mapping.clone(); - process_program_type_alias(program, type_alias_mapping); + type_alias_pass(program, type_alias_mapping); + // Erase all the function type to "function" on ast + type_func_erasure_pass(program); } - // erase all the function type to "function" on ast - type_erasure(program); scope } diff --git a/kclvm/sema/src/resolver/node.rs b/kclvm/sema/src/resolver/node.rs index 6db1cc277..7cf23bdbe 100644 --- a/kclvm/sema/src/resolver/node.rs +++ b/kclvm/sema/src/resolver/node.rs @@ -170,10 +170,7 @@ impl<'ctx> MutSelfTypedResultWalker<'ctx> for Resolver<'ctx> { target.get_span_pos(), None, ); - if !value_ty.is_any() - && expected_ty.is_any() - && assign_stmt.type_annotation.is_none() - { + if !value_ty.is_any() && expected_ty.is_any() && assign_stmt.ty.is_none() { self.set_type_to_scope(name, value_ty.clone(), &target.node.names[0]); if let Some(schema_ty) = &self.ctx.schema { let mut schema_ty = schema_ty.borrow_mut(); @@ -997,7 +994,7 @@ impl<'ctx> MutSelfTypedResultWalker<'ctx> for Resolver<'ctx> { self.leave_scope(); self.ctx.in_lambda_expr.pop(); self.must_assignable_to(real_ret_ty.clone(), ret_ty.clone(), (start, end), None); - if !real_ret_ty.is_any() && ret_ty.is_any() && lambda_expr.return_type_str.is_none() { + if !real_ret_ty.is_any() && ret_ty.is_any() && lambda_expr.return_ty.is_none() { ret_ty = real_ret_ty; } Arc::new(Type::function(None, ret_ty, ¶ms, "", false, None)) diff --git a/kclvm/sema/src/resolver/tests.rs b/kclvm/sema/src/resolver/tests.rs index 138ac4eae..dfc141f61 100644 --- a/kclvm/sema/src/resolver/tests.rs +++ b/kclvm/sema/src/resolver/tests.rs @@ -55,7 +55,7 @@ fn test_resolve_program_with_cache() { &mut program, Options { merge_program: false, - type_alise: false, + type_erasure: false, ..Default::default() }, None, @@ -65,7 +65,7 @@ fn test_resolve_program_with_cache() { &mut program, Options { merge_program: false, - type_alise: false, + type_erasure: false, ..Default::default() }, Some(cached_scope), diff --git a/kclvm/sema/src/resolver/ty.rs b/kclvm/sema/src/resolver/ty.rs index dc7d4a4a6..ffe3c7a03 100644 --- a/kclvm/sema/src/resolver/ty.rs +++ b/kclvm/sema/src/resolver/ty.rs @@ -137,7 +137,7 @@ impl<'ctx> Resolver<'ctx> { assign_stmt: &kclvm_ast::ast::AssignStmt, value_ty: TypeRef, ) { - if assign_stmt.type_annotation.is_none() { + if assign_stmt.ty.is_none() { return; } for target in &assign_stmt.targets { diff --git a/kclvm/sema/src/resolver/ty_alias.rs b/kclvm/sema/src/resolver/ty_alias.rs index 26b8fbeb2..7139107f1 100644 --- a/kclvm/sema/src/resolver/ty_alias.rs +++ b/kclvm/sema/src/resolver/ty_alias.rs @@ -25,15 +25,15 @@ impl<'ctx> MutSelfMutWalker<'ctx> for TypeAliasTransformer { let value = &mut schema_index_signature.node.value; if let Some(type_alias) = self .type_alias_mapping - .get(&schema_index_signature.node.key_type.node) + .get(&schema_index_signature.node.key_ty.node.to_string()) { - schema_index_signature.node.key_type.node = type_alias.clone(); + schema_index_signature.node.key_ty.node = type_alias.clone().into(); } if let Some(type_alias) = self .type_alias_mapping - .get(&schema_index_signature.node.value_type.node) + .get(&schema_index_signature.node.value_ty.node.to_string()) { - schema_index_signature.node.value_type.node = type_alias.clone(); + schema_index_signature.node.value_ty.node = type_alias.clone().into(); } walk_if_mut!(self, walk_expr, value); } @@ -44,15 +44,18 @@ impl<'ctx> MutSelfMutWalker<'ctx> for TypeAliasTransformer { } fn walk_schema_attr(&mut self, schema_attr: &'ctx mut ast::SchemaAttr) { // walk_list_mut!(self, walk_call_expr, schema_attr.decorators); - if let Some(type_alias) = self.type_alias_mapping.get(&schema_attr.type_str.node) { - schema_attr.type_str.node = type_alias.clone(); + if let Some(type_alias) = self + .type_alias_mapping + .get(&schema_attr.ty.node.to_string()) + { + schema_attr.ty.node = type_alias.clone().into(); } walk_if_mut!(self, walk_expr, schema_attr.value); } fn walk_assign_stmt(&mut self, assign_stmt: &'ctx mut ast::AssignStmt) { - if let Some(ty_str) = &mut assign_stmt.type_annotation { - if let Some(type_alias) = self.type_alias_mapping.get(&ty_str.node) { - ty_str.node = type_alias.clone(); + if let Some(ty) = &mut assign_stmt.ty { + if let Some(type_alias) = self.type_alias_mapping.get(&ty.node.to_string()) { + ty.node = type_alias.clone().into(); } } self.walk_expr(&mut assign_stmt.value.node); @@ -64,17 +67,20 @@ impl<'ctx> MutSelfMutWalker<'ctx> for TypeAliasTransformer { fn walk_lambda_expr(&mut self, lambda_expr: &'ctx mut ast::LambdaExpr) { walk_if_mut!(self, walk_arguments, lambda_expr.args); walk_list_mut!(self, walk_stmt, lambda_expr.body); - if let Some(ty_str) = &mut lambda_expr.return_type_str { - if let Some(type_alias) = self.type_alias_mapping.get(ty_str) { - *ty_str = type_alias.clone(); + if let Some(ty) = &mut lambda_expr.return_ty { + if let Some(type_alias) = self.type_alias_mapping.get(&ty.node.to_string()) { + ty.node = type_alias.clone().into(); } } } fn walk_arguments(&mut self, arguments: &'ctx mut ast::Arguments) { walk_list_mut!(self, walk_identifier, arguments.args); - for type_annotation in (&mut arguments.type_annotation_list.iter_mut()).flatten() { - if let Some(type_alias) = self.type_alias_mapping.get(&type_annotation.node) { - type_annotation.node = type_alias.clone(); + for type_annotation in (&mut arguments.ty_list.iter_mut()).flatten() { + if let Some(type_alias) = self + .type_alias_mapping + .get(&type_annotation.node.to_string()) + { + type_annotation.node = type_alias.clone().into(); } } for default in arguments.defaults.iter_mut() { @@ -135,7 +141,7 @@ fn fix_type_alias_identifier<'ctx>( } /// Process type alias. -pub fn process_program_type_alias( +pub fn type_alias_pass( program: &mut ast::Program, type_alias_mapping: IndexMap>, ) { diff --git a/kclvm/sema/src/resolver/type_erasure.rs b/kclvm/sema/src/resolver/ty_erasure.rs similarity index 69% rename from kclvm/sema/src/resolver/type_erasure.rs rename to kclvm/sema/src/resolver/ty_erasure.rs index e635393af..0d0f269ef 100644 --- a/kclvm/sema/src/resolver/type_erasure.rs +++ b/kclvm/sema/src/resolver/ty_erasure.rs @@ -11,7 +11,7 @@ impl<'ctx> MutSelfMutWalker<'ctx> for TypeErasureTransformer { if let kclvm_ast::ast::Type::Function(_) = &mut schema_index_signature.node.value_ty.node { - schema_index_signature.node.value_type.node = FUNCTION.to_string(); + schema_index_signature.node.value_ty.node = FUNCTION.to_string().into(); } } for item in schema_stmt.body.iter_mut() { @@ -23,14 +23,14 @@ impl<'ctx> MutSelfMutWalker<'ctx> for TypeErasureTransformer { fn walk_schema_attr(&mut self, schema_attr: &'ctx mut ast::SchemaAttr) { if let kclvm_ast::ast::Type::Function(_) = schema_attr.ty.as_ref().node { - schema_attr.type_str.node = FUNCTION.to_string(); + schema_attr.ty.node = FUNCTION.to_string().into(); } } fn walk_assign_stmt(&mut self, assign_stmt: &'ctx mut ast::AssignStmt) { if let Some(ty) = &mut assign_stmt.ty { if let kclvm_ast::ast::Type::Function(_) = ty.as_ref().node { - if let Some(ty_anno) = &mut assign_stmt.type_annotation { - ty_anno.node = FUNCTION.to_string(); + if let Some(ty_anno) = &mut assign_stmt.ty { + ty_anno.node = FUNCTION.to_string().into(); } } } @@ -41,23 +41,16 @@ impl<'ctx> MutSelfMutWalker<'ctx> for TypeErasureTransformer { } } fn walk_arguments(&mut self, arguments: &'ctx mut ast::Arguments) { - for (ty, ty_anno) in arguments - .ty_list - .iter_mut() - .zip(arguments.type_annotation_list.iter_mut()) - { - if let Some(ty) = ty { - if let kclvm_ast::ast::Type::Function(_) = ty.as_ref().node { - if let Some(ty_anno) = ty_anno { - ty_anno.node = FUNCTION.to_string(); - } - } + for ty in (&mut arguments.ty_list.iter_mut()).flatten() { + if let kclvm_ast::ast::Type::Function(_) = ty.as_ref().node { + ty.node = FUNCTION.to_string().into(); } } } } -pub fn type_erasure<'ctx>(program: &'ctx mut ast::Program) { +/// Run a pass on AST and change the function type to the `Named("function")` type +pub fn type_func_erasure_pass<'ctx>(program: &'ctx mut ast::Program) { for (_, modules) in program.pkgs.iter_mut() { for module in modules.iter_mut() { TypeErasureTransformer::default().walk_module(module); diff --git a/kclvm/tools/src/LSP/src/rename.rs b/kclvm/tools/src/LSP/src/rename.rs index 5d95e8c13..d8695a7f7 100644 --- a/kclvm/tools/src/LSP/src/rename.rs +++ b/kclvm/tools/src/LSP/src/rename.rs @@ -193,7 +193,7 @@ where &mut program, kclvm_sema::resolver::Options { merge_program: false, - type_alise: false, + type_erasure: false, ..Default::default() }, None, diff --git a/kclvm/tools/src/LSP/src/util.rs b/kclvm/tools/src/LSP/src/util.rs index 968041435..38841f92d 100644 --- a/kclvm/tools/src/LSP/src/util.rs +++ b/kclvm/tools/src/LSP/src/util.rs @@ -3,6 +3,7 @@ use kclvm_ast::ast::{ ConfigEntry, Expr, Identifier, Node, NodeRef, PosTuple, Program, SchemaExpr, SchemaStmt, Stmt, Type, }; +use kclvm_ast::node_ref; use kclvm_ast::pos::ContainsPos; use kclvm_driver::kpm_metadata::fetch_metadata; @@ -89,7 +90,7 @@ pub(crate) fn parse_param_and_compile( &mut program, kclvm_sema::resolver::Options { merge_program: false, - type_alise: false, + type_erasure: false, ..Default::default() }, None, @@ -552,9 +553,15 @@ pub(crate) fn inner_most_expr( for default in &argument.defaults { walk_option_if_contains!(default, pos, schema_def); } - for ty in argument.type_annotation_list.iter().flatten() { + for ty in argument.ty_list.iter().flatten() { if ty.contains_pos(pos) { - return (Some(build_identifier_from_string(ty)), schema_def); + return ( + Some(build_identifier_from_string(&node_ref!( + ty.node.to_string(), + ty.pos() + ))), + schema_def, + ); } } (Some(expr.clone()), schema_def) diff --git a/kclvm/tools/src/vet/validator.rs b/kclvm/tools/src/vet/validator.rs index 6deb8f4d3..e7fe40349 100644 --- a/kclvm/tools/src/vet/validator.rs +++ b/kclvm/tools/src/vet/validator.rs @@ -206,7 +206,6 @@ fn build_assign(attr_name: &str, node: NodeRef) -> NodeRef { ctx: ExprContext::Store, })], value: node, - type_annotation: None, ty: None, })) }