From b758a071dc0208960495f7a5ce305d3241ddf3af Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Wed, 3 Mar 2021 14:08:57 +0000 Subject: [PATCH] Initial commit --- .gitignore | 149 +++ LICENSE | 26 + README.md | 35 + chocopy-ref.jar | Bin 0 -> 144775 bytes pom.xml | 330 ++++++ src/main/java/chocopy/common/Utils.java | 54 + .../common/analysis/AbstractNodeAnalyzer.java | 174 ++++ .../chocopy/common/analysis/NodeAnalyzer.java | 93 ++ .../chocopy/common/analysis/SymbolTable.java | 62 ++ .../common/analysis/types/ClassValueType.java | 53 + .../common/analysis/types/FuncType.java | 45 + .../common/analysis/types/ListValueType.java | 57 ++ .../chocopy/common/analysis/types/Type.java | 68 ++ .../common/analysis/types/ValueType.java | 29 + .../chocopy/common/astnodes/AssignStmt.java | 25 + .../chocopy/common/astnodes/BinaryExpr.java | 31 + .../common/astnodes/BooleanLiteral.java | 21 + .../chocopy/common/astnodes/CallExpr.java | 26 + .../chocopy/common/astnodes/ClassDef.java | 39 + .../chocopy/common/astnodes/ClassType.java | 21 + .../common/astnodes/CompilerError.java | 56 ++ .../chocopy/common/astnodes/Declaration.java | 17 + .../java/chocopy/common/astnodes/Errors.java | 71 ++ .../java/chocopy/common/astnodes/Expr.java | 43 + .../chocopy/common/astnodes/ExprStmt.java | 21 + .../java/chocopy/common/astnodes/ForStmt.java | 29 + .../java/chocopy/common/astnodes/FuncDef.java | 50 + .../chocopy/common/astnodes/GlobalDecl.java | 26 + .../chocopy/common/astnodes/Identifier.java | 24 + .../java/chocopy/common/astnodes/IfExpr.java | 26 + .../java/chocopy/common/astnodes/IfStmt.java | 35 + .../chocopy/common/astnodes/IndexExpr.java | 24 + .../common/astnodes/IntegerLiteral.java | 21 + .../chocopy/common/astnodes/ListExpr.java | 23 + .../chocopy/common/astnodes/ListType.java | 21 + .../java/chocopy/common/astnodes/Literal.java | 16 + .../chocopy/common/astnodes/MemberExpr.java | 24 + .../common/astnodes/MethodCallExpr.java | 26 + .../java/chocopy/common/astnodes/Node.java | 176 ++++ .../chocopy/common/astnodes/NonLocalDecl.java | 26 + .../chocopy/common/astnodes/NoneLiteral.java | 17 + .../java/chocopy/common/astnodes/Program.java | 56 ++ .../chocopy/common/astnodes/ReturnStmt.java | 21 + .../java/chocopy/common/astnodes/Stmt.java | 18 + .../common/astnodes/StringLiteral.java | 21 + .../common/astnodes/TypeAnnotation.java | 11 + .../chocopy/common/astnodes/TypedVar.java | 24 + .../chocopy/common/astnodes/UnaryExpr.java | 24 + .../java/chocopy/common/astnodes/VarDef.java | 32 + .../chocopy/common/astnodes/WhileStmt.java | 25 + .../java/chocopy/pa2/DeclarationAnalyzer.java | 55 + .../java/chocopy/pa2/StudentAnalysis.java | 30 + src/main/java/chocopy/pa2/TypeChecker.java | 94 ++ src/test/data/pa2/sample/ast_coverage.py | 38 + src/test/data/pa2/sample/ast_coverage.py.ast | 627 ++++++++++++ .../data/pa2/sample/ast_coverage.py.ast.typed | 952 ++++++++++++++++++ src/test/data/pa2/sample/bad_assign_expr.py | 11 + .../data/pa2/sample/bad_assign_expr.py.ast | 177 ++++ .../pa2/sample/bad_assign_expr.py.ast.typed | 301 ++++++ src/test/data/pa2/sample/bad_class_attr.py | 13 + .../data/pa2/sample/bad_class_attr.py.ast | 155 +++ .../pa2/sample/bad_class_attr.py.ast.typed | 165 +++ .../data/pa2/sample/bad_class_attr_type.py | 4 + .../pa2/sample/bad_class_attr_type.py.ast | 60 ++ .../sample/bad_class_attr_type.py.ast.typed | 73 ++ .../pa2/sample/bad_class_init_override.py | 8 + .../pa2/sample/bad_class_init_override.py.ast | 106 ++ .../bad_class_init_override.py.ast.typed | 111 ++ .../data/pa2/sample/bad_class_init_return.py | 5 + .../pa2/sample/bad_class_init_return.py.ast | 75 ++ .../sample/bad_class_init_return.py.ast.typed | 88 ++ .../data/pa2/sample/bad_class_member_expr.py | 6 + .../pa2/sample/bad_class_member_expr.py.ast | 110 ++ .../sample/bad_class_member_expr.py.ast.typed | 161 +++ src/test/data/pa2/sample/bad_class_method.py | 14 + .../data/pa2/sample/bad_class_method.py.ast | 158 +++ .../pa2/sample/bad_class_method.py.ast.typed | 168 ++++ .../pa2/sample/bad_class_method_invoke.py | 30 + .../pa2/sample/bad_class_method_invoke.py.ast | 474 +++++++++ .../bad_class_method_invoke.py.ast.typed | 668 ++++++++++++ .../pa2/sample/bad_class_method_override.py | 33 + .../sample/bad_class_method_override.py.ast | 439 ++++++++ .../bad_class_method_override.py.ast.typed | 454 +++++++++ .../sample/bad_class_method_override_attr.py | 8 + .../bad_class_method_override_attr.py.ast | 111 ++ ...ad_class_method_override_attr.py.ast.typed | 116 +++ src/test/data/pa2/sample/bad_class_super.py | 15 + .../data/pa2/sample/bad_class_super.py.ast | 154 +++ .../pa2/sample/bad_class_super.py.ast.typed | 169 ++++ src/test/data/pa2/sample/bad_concat.py | 3 + src/test/data/pa2/sample/bad_concat.py.ast | 77 ++ .../data/pa2/sample/bad_concat.py.ast.typed | 149 +++ .../data/pa2/sample/bad_duplicate_class.py | 18 + .../pa2/sample/bad_duplicate_class.py.ast | 190 ++++ .../sample/bad_duplicate_class.py.ast.typed | 205 ++++ .../pa2/sample/bad_duplicate_class_member.py | 12 + .../sample/bad_duplicate_class_member.py.ast | 156 +++ .../bad_duplicate_class_member.py.ast.typed | 166 +++ .../data/pa2/sample/bad_duplicate_global.py | 18 + .../pa2/sample/bad_duplicate_global.py.ast | 129 +++ .../sample/bad_duplicate_global.py.ast.typed | 144 +++ .../data/pa2/sample/bad_duplicate_global_2.py | 6 + .../pa2/sample/bad_duplicate_global_2.py.ast | 47 + .../bad_duplicate_global_2.py.ast.typed | 52 + .../data/pa2/sample/bad_duplicate_local.py | 21 + .../pa2/sample/bad_duplicate_local.py.ast | 257 +++++ .../sample/bad_duplicate_local.py.ast.typed | 277 +++++ src/test/data/pa2/sample/bad_expr_binary.py | 13 + .../data/pa2/sample/bad_expr_binary.py.ast | 239 +++++ .../pa2/sample/bad_expr_binary.py.ast.typed | 455 +++++++++ src/test/data/pa2/sample/bad_expr_if.py | 2 + src/test/data/pa2/sample/bad_expr_if.py.ast | 70 ++ .../data/pa2/sample/bad_expr_if.py.ast.typed | 107 ++ src/test/data/pa2/sample/bad_expr_unary.py | 4 + .../data/pa2/sample/bad_expr_unary.py.ast | 62 ++ .../pa2/sample/bad_expr_unary.py.ast.typed | 114 +++ src/test/data/pa2/sample/bad_func_def_call.py | 13 + .../data/pa2/sample/bad_func_def_call.py.ast | 187 ++++ .../pa2/sample/bad_func_def_call.py.ast.typed | 336 +++++++ .../data/pa2/sample/bad_func_def_return.py | 10 + .../pa2/sample/bad_func_def_return.py.ast | 125 +++ .../sample/bad_func_def_return.py.ast.typed | 174 ++++ src/test/data/pa2/sample/bad_list_assign.py | 6 + .../data/pa2/sample/bad_list_assign.py.ast | 116 +++ .../pa2/sample/bad_list_assign.py.ast.typed | 192 ++++ src/test/data/pa2/sample/bad_list_index.py | 7 + .../data/pa2/sample/bad_list_index.py.ast | 147 +++ .../pa2/sample/bad_list_index.py.ast.typed | 275 +++++ src/test/data/pa2/sample/bad_local_assign.py | 23 + .../data/pa2/sample/bad_local_assign.py.ast | 253 +++++ .../pa2/sample/bad_local_assign.py.ast.typed | 330 ++++++ src/test/data/pa2/sample/bad_none_assign.py | 14 + .../data/pa2/sample/bad_none_assign.py.ast | 187 ++++ .../pa2/sample/bad_none_assign.py.ast.typed | 265 +++++ .../data/pa2/sample/bad_nonlocal_global.py | 25 + .../pa2/sample/bad_nonlocal_global.py.ast | 229 +++++ .../sample/bad_nonlocal_global.py.ast.typed | 259 +++++ .../data/pa2/sample/bad_return_missing.py | 6 + .../data/pa2/sample/bad_return_missing.py.ast | 58 ++ .../sample/bad_return_missing.py.ast.typed | 63 ++ src/test/data/pa2/sample/bad_return_top.py | 3 + .../data/pa2/sample/bad_return_top.py.ast | 41 + .../pa2/sample/bad_return_top.py.ast.typed | 50 + src/test/data/pa2/sample/bad_shadow_local.py | 14 + .../data/pa2/sample/bad_shadow_local.py.ast | 179 ++++ .../pa2/sample/bad_shadow_local.py.ast.typed | 199 ++++ .../data/pa2/sample/bad_shadow_local_2.py | 8 + .../data/pa2/sample/bad_shadow_local_2.py.ast | 98 ++ .../sample/bad_shadow_local_2.py.ast.typed | 103 ++ src/test/data/pa2/sample/bad_strings.py | 10 + src/test/data/pa2/sample/bad_strings.py.ast | 183 ++++ .../data/pa2/sample/bad_strings.py.ast.typed | 301 ++++++ .../data/pa2/sample/bad_type_annotation.py | 7 + .../pa2/sample/bad_type_annotation.py.ast | 86 ++ .../sample/bad_type_annotation.py.ast.typed | 106 ++ src/test/data/pa2/sample/bad_type_id.py | 1 + src/test/data/pa2/sample/bad_type_id.py.ast | 29 + .../data/pa2/sample/bad_type_id.py.ast.typed | 51 + src/test/data/pa2/sample/bad_var_assign.py | 8 + .../data/pa2/sample/bad_var_assign.py.ast | 127 +++ .../pa2/sample/bad_var_assign.py.ast.typed | 213 ++++ src/test/data/pa2/sample/class_def_assign.py | 18 + .../data/pa2/sample/class_def_assign.py.ast | 263 +++++ .../pa2/sample/class_def_assign.py.ast.typed | 323 ++++++ src/test/data/pa2/sample/class_def_attr.py | 22 + .../data/pa2/sample/class_def_attr.py.ast | 346 +++++++ .../pa2/sample/class_def_attr.py.ast.typed | 446 ++++++++ src/test/data/pa2/sample/class_def_init.py | 17 + .../data/pa2/sample/class_def_init.py.ast | 243 +++++ .../pa2/sample/class_def_init.py.ast.typed | 287 ++++++ src/test/data/pa2/sample/class_def_methods.py | 28 + .../data/pa2/sample/class_def_methods.py.ast | 451 +++++++++ .../pa2/sample/class_def_methods.py.ast.typed | 595 +++++++++++ .../data/pa2/sample/decl_global_forward.py | 9 + .../pa2/sample/decl_global_forward.py.ast | 108 ++ .../sample/decl_global_forward.py.ast.typed | 155 +++ .../data/pa2/sample/decl_nonlocal_forward.py | 10 + .../pa2/sample/decl_nonlocal_forward.py.ast | 137 +++ .../sample/decl_nonlocal_forward.py.ast.typed | 196 ++++ src/test/data/pa2/sample/expr_binary.py | 2 + src/test/data/pa2/sample/expr_binary.py.ast | 109 ++ .../data/pa2/sample/expr_binary.py.ast.typed | 185 ++++ src/test/data/pa2/sample/expr_concat.py | 3 + src/test/data/pa2/sample/expr_concat.py.ast | 93 ++ .../data/pa2/sample/expr_concat.py.ast.typed | 175 ++++ src/test/data/pa2/sample/expr_id.py | 3 + src/test/data/pa2/sample/expr_id.py.ast | 51 + src/test/data/pa2/sample/expr_id.py.ast.typed | 67 ++ src/test/data/pa2/sample/expr_if.py | 1 + src/test/data/pa2/sample/expr_if.py.ast | 43 + src/test/data/pa2/sample/expr_if.py.ast.typed | 67 ++ src/test/data/pa2/sample/expr_int.py | 1 + src/test/data/pa2/sample/expr_int.py.ast | 29 + .../data/pa2/sample/expr_int.py.ast.typed | 41 + src/test/data/pa2/sample/expr_list_index.py | 12 + .../data/pa2/sample/expr_list_index.py.ast | 247 +++++ .../pa2/sample/expr_list_index.py.ast.typed | 398 ++++++++ src/test/data/pa2/sample/expr_lists.py | 12 + src/test/data/pa2/sample/expr_lists.py.ast | 233 +++++ .../data/pa2/sample/expr_lists.py.ast.typed | 374 +++++++ src/test/data/pa2/sample/expr_unary.py | 2 + src/test/data/pa2/sample/expr_unary.py.ast | 37 + .../data/pa2/sample/expr_unary.py.ast.typed | 53 + src/test/data/pa2/sample/expr_var_assign.py | 4 + .../data/pa2/sample/expr_var_assign.py.ast | 71 ++ .../pa2/sample/expr_var_assign.py.ast.typed | 91 ++ src/test/data/pa2/sample/func_def_call.py | 7 + src/test/data/pa2/sample/func_def_call.py.ast | 111 ++ .../pa2/sample/func_def_call.py.ast.typed | 153 +++ src/test/data/pa2/sample/stmt_for_lists.py | 4 + .../data/pa2/sample/stmt_for_lists.py.ast | 77 ++ .../pa2/sample/stmt_for_lists.py.ast.typed | 116 +++ src/test/data/pa2/sample/stmt_for_strings.py | 4 + .../data/pa2/sample/stmt_for_strings.py.ast | 64 ++ .../pa2/sample/stmt_for_strings.py.ast.typed | 88 ++ src/test/data/pa2/sample/stmt_if.py | 7 + src/test/data/pa2/sample/stmt_if.py.ast | 51 + src/test/data/pa2/sample/stmt_if.py.ast.typed | 71 ++ src/test/data/pa2/sample/stmt_list_assign.py | 7 + .../data/pa2/sample/stmt_list_assign.py.ast | 155 +++ .../pa2/sample/stmt_list_assign.py.ast.typed | 256 +++++ src/test/data/pa2/sample/stmt_var_assign.py | 9 + .../data/pa2/sample/stmt_var_assign.py.ast | 150 +++ .../pa2/sample/stmt_var_assign.py.ast.typed | 198 ++++ src/test/data/pa2/sample/stmt_while.py | 3 + src/test/data/pa2/sample/stmt_while.py.ast | 75 ++ .../data/pa2/sample/stmt_while.py.ast.typed | 107 ++ src/test/data/pa2/sample/strings.py | 8 + src/test/data/pa2/sample/strings.py.ast | 139 +++ src/test/data/pa2/sample/strings.py.ast.typed | 195 ++++ .../pa2/student_contributed/bad_semantic.py | 4 + .../data/pa2/student_contributed/bad_types.py | 2 + src/test/data/pa2/student_contributed/good.py | 2 + 233 files changed, 25009 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 chocopy-ref.jar create mode 100644 pom.xml create mode 100644 src/main/java/chocopy/common/Utils.java create mode 100644 src/main/java/chocopy/common/analysis/AbstractNodeAnalyzer.java create mode 100644 src/main/java/chocopy/common/analysis/NodeAnalyzer.java create mode 100644 src/main/java/chocopy/common/analysis/SymbolTable.java create mode 100644 src/main/java/chocopy/common/analysis/types/ClassValueType.java create mode 100644 src/main/java/chocopy/common/analysis/types/FuncType.java create mode 100644 src/main/java/chocopy/common/analysis/types/ListValueType.java create mode 100644 src/main/java/chocopy/common/analysis/types/Type.java create mode 100644 src/main/java/chocopy/common/analysis/types/ValueType.java create mode 100644 src/main/java/chocopy/common/astnodes/AssignStmt.java create mode 100644 src/main/java/chocopy/common/astnodes/BinaryExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/BooleanLiteral.java create mode 100644 src/main/java/chocopy/common/astnodes/CallExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/ClassDef.java create mode 100644 src/main/java/chocopy/common/astnodes/ClassType.java create mode 100644 src/main/java/chocopy/common/astnodes/CompilerError.java create mode 100644 src/main/java/chocopy/common/astnodes/Declaration.java create mode 100644 src/main/java/chocopy/common/astnodes/Errors.java create mode 100644 src/main/java/chocopy/common/astnodes/Expr.java create mode 100644 src/main/java/chocopy/common/astnodes/ExprStmt.java create mode 100644 src/main/java/chocopy/common/astnodes/ForStmt.java create mode 100644 src/main/java/chocopy/common/astnodes/FuncDef.java create mode 100644 src/main/java/chocopy/common/astnodes/GlobalDecl.java create mode 100644 src/main/java/chocopy/common/astnodes/Identifier.java create mode 100644 src/main/java/chocopy/common/astnodes/IfExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/IfStmt.java create mode 100644 src/main/java/chocopy/common/astnodes/IndexExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/IntegerLiteral.java create mode 100644 src/main/java/chocopy/common/astnodes/ListExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/ListType.java create mode 100644 src/main/java/chocopy/common/astnodes/Literal.java create mode 100644 src/main/java/chocopy/common/astnodes/MemberExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/MethodCallExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/Node.java create mode 100644 src/main/java/chocopy/common/astnodes/NonLocalDecl.java create mode 100644 src/main/java/chocopy/common/astnodes/NoneLiteral.java create mode 100644 src/main/java/chocopy/common/astnodes/Program.java create mode 100644 src/main/java/chocopy/common/astnodes/ReturnStmt.java create mode 100644 src/main/java/chocopy/common/astnodes/Stmt.java create mode 100644 src/main/java/chocopy/common/astnodes/StringLiteral.java create mode 100644 src/main/java/chocopy/common/astnodes/TypeAnnotation.java create mode 100644 src/main/java/chocopy/common/astnodes/TypedVar.java create mode 100644 src/main/java/chocopy/common/astnodes/UnaryExpr.java create mode 100644 src/main/java/chocopy/common/astnodes/VarDef.java create mode 100644 src/main/java/chocopy/common/astnodes/WhileStmt.java create mode 100644 src/main/java/chocopy/pa2/DeclarationAnalyzer.java create mode 100644 src/main/java/chocopy/pa2/StudentAnalysis.java create mode 100644 src/main/java/chocopy/pa2/TypeChecker.java create mode 100644 src/test/data/pa2/sample/ast_coverage.py create mode 100644 src/test/data/pa2/sample/ast_coverage.py.ast create mode 100644 src/test/data/pa2/sample/ast_coverage.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_assign_expr.py create mode 100644 src/test/data/pa2/sample/bad_assign_expr.py.ast create mode 100644 src/test/data/pa2/sample/bad_assign_expr.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_attr.py create mode 100644 src/test/data/pa2/sample/bad_class_attr.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_attr.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_attr_type.py create mode 100644 src/test/data/pa2/sample/bad_class_attr_type.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_attr_type.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_init_override.py create mode 100644 src/test/data/pa2/sample/bad_class_init_override.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_init_override.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_init_return.py create mode 100644 src/test/data/pa2/sample/bad_class_init_return.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_init_return.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_member_expr.py create mode 100644 src/test/data/pa2/sample/bad_class_member_expr.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_member_expr.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_method.py create mode 100644 src/test/data/pa2/sample/bad_class_method.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_method.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_method_invoke.py create mode 100644 src/test/data/pa2/sample/bad_class_method_invoke.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_method_invoke.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_method_override.py create mode 100644 src/test/data/pa2/sample/bad_class_method_override.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_method_override.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_method_override_attr.py create mode 100644 src/test/data/pa2/sample/bad_class_method_override_attr.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_method_override_attr.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_class_super.py create mode 100644 src/test/data/pa2/sample/bad_class_super.py.ast create mode 100644 src/test/data/pa2/sample/bad_class_super.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_concat.py create mode 100644 src/test/data/pa2/sample/bad_concat.py.ast create mode 100644 src/test/data/pa2/sample/bad_concat.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_duplicate_class.py create mode 100644 src/test/data/pa2/sample/bad_duplicate_class.py.ast create mode 100644 src/test/data/pa2/sample/bad_duplicate_class.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_duplicate_class_member.py create mode 100644 src/test/data/pa2/sample/bad_duplicate_class_member.py.ast create mode 100644 src/test/data/pa2/sample/bad_duplicate_class_member.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_duplicate_global.py create mode 100644 src/test/data/pa2/sample/bad_duplicate_global.py.ast create mode 100644 src/test/data/pa2/sample/bad_duplicate_global.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_duplicate_global_2.py create mode 100644 src/test/data/pa2/sample/bad_duplicate_global_2.py.ast create mode 100644 src/test/data/pa2/sample/bad_duplicate_global_2.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_duplicate_local.py create mode 100644 src/test/data/pa2/sample/bad_duplicate_local.py.ast create mode 100644 src/test/data/pa2/sample/bad_duplicate_local.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_expr_binary.py create mode 100644 src/test/data/pa2/sample/bad_expr_binary.py.ast create mode 100644 src/test/data/pa2/sample/bad_expr_binary.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_expr_if.py create mode 100644 src/test/data/pa2/sample/bad_expr_if.py.ast create mode 100644 src/test/data/pa2/sample/bad_expr_if.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_expr_unary.py create mode 100644 src/test/data/pa2/sample/bad_expr_unary.py.ast create mode 100644 src/test/data/pa2/sample/bad_expr_unary.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_func_def_call.py create mode 100644 src/test/data/pa2/sample/bad_func_def_call.py.ast create mode 100644 src/test/data/pa2/sample/bad_func_def_call.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_func_def_return.py create mode 100644 src/test/data/pa2/sample/bad_func_def_return.py.ast create mode 100644 src/test/data/pa2/sample/bad_func_def_return.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_list_assign.py create mode 100644 src/test/data/pa2/sample/bad_list_assign.py.ast create mode 100644 src/test/data/pa2/sample/bad_list_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_list_index.py create mode 100644 src/test/data/pa2/sample/bad_list_index.py.ast create mode 100644 src/test/data/pa2/sample/bad_list_index.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_local_assign.py create mode 100644 src/test/data/pa2/sample/bad_local_assign.py.ast create mode 100644 src/test/data/pa2/sample/bad_local_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_none_assign.py create mode 100644 src/test/data/pa2/sample/bad_none_assign.py.ast create mode 100644 src/test/data/pa2/sample/bad_none_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_nonlocal_global.py create mode 100644 src/test/data/pa2/sample/bad_nonlocal_global.py.ast create mode 100644 src/test/data/pa2/sample/bad_nonlocal_global.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_return_missing.py create mode 100644 src/test/data/pa2/sample/bad_return_missing.py.ast create mode 100644 src/test/data/pa2/sample/bad_return_missing.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_return_top.py create mode 100644 src/test/data/pa2/sample/bad_return_top.py.ast create mode 100644 src/test/data/pa2/sample/bad_return_top.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_shadow_local.py create mode 100644 src/test/data/pa2/sample/bad_shadow_local.py.ast create mode 100644 src/test/data/pa2/sample/bad_shadow_local.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_shadow_local_2.py create mode 100644 src/test/data/pa2/sample/bad_shadow_local_2.py.ast create mode 100644 src/test/data/pa2/sample/bad_shadow_local_2.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_strings.py create mode 100644 src/test/data/pa2/sample/bad_strings.py.ast create mode 100644 src/test/data/pa2/sample/bad_strings.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_type_annotation.py create mode 100644 src/test/data/pa2/sample/bad_type_annotation.py.ast create mode 100644 src/test/data/pa2/sample/bad_type_annotation.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_type_id.py create mode 100644 src/test/data/pa2/sample/bad_type_id.py.ast create mode 100644 src/test/data/pa2/sample/bad_type_id.py.ast.typed create mode 100644 src/test/data/pa2/sample/bad_var_assign.py create mode 100644 src/test/data/pa2/sample/bad_var_assign.py.ast create mode 100644 src/test/data/pa2/sample/bad_var_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/class_def_assign.py create mode 100644 src/test/data/pa2/sample/class_def_assign.py.ast create mode 100644 src/test/data/pa2/sample/class_def_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/class_def_attr.py create mode 100644 src/test/data/pa2/sample/class_def_attr.py.ast create mode 100644 src/test/data/pa2/sample/class_def_attr.py.ast.typed create mode 100644 src/test/data/pa2/sample/class_def_init.py create mode 100644 src/test/data/pa2/sample/class_def_init.py.ast create mode 100644 src/test/data/pa2/sample/class_def_init.py.ast.typed create mode 100644 src/test/data/pa2/sample/class_def_methods.py create mode 100644 src/test/data/pa2/sample/class_def_methods.py.ast create mode 100644 src/test/data/pa2/sample/class_def_methods.py.ast.typed create mode 100644 src/test/data/pa2/sample/decl_global_forward.py create mode 100644 src/test/data/pa2/sample/decl_global_forward.py.ast create mode 100644 src/test/data/pa2/sample/decl_global_forward.py.ast.typed create mode 100644 src/test/data/pa2/sample/decl_nonlocal_forward.py create mode 100644 src/test/data/pa2/sample/decl_nonlocal_forward.py.ast create mode 100644 src/test/data/pa2/sample/decl_nonlocal_forward.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_binary.py create mode 100644 src/test/data/pa2/sample/expr_binary.py.ast create mode 100644 src/test/data/pa2/sample/expr_binary.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_concat.py create mode 100644 src/test/data/pa2/sample/expr_concat.py.ast create mode 100644 src/test/data/pa2/sample/expr_concat.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_id.py create mode 100644 src/test/data/pa2/sample/expr_id.py.ast create mode 100644 src/test/data/pa2/sample/expr_id.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_if.py create mode 100644 src/test/data/pa2/sample/expr_if.py.ast create mode 100644 src/test/data/pa2/sample/expr_if.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_int.py create mode 100644 src/test/data/pa2/sample/expr_int.py.ast create mode 100644 src/test/data/pa2/sample/expr_int.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_list_index.py create mode 100644 src/test/data/pa2/sample/expr_list_index.py.ast create mode 100644 src/test/data/pa2/sample/expr_list_index.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_lists.py create mode 100644 src/test/data/pa2/sample/expr_lists.py.ast create mode 100644 src/test/data/pa2/sample/expr_lists.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_unary.py create mode 100644 src/test/data/pa2/sample/expr_unary.py.ast create mode 100644 src/test/data/pa2/sample/expr_unary.py.ast.typed create mode 100644 src/test/data/pa2/sample/expr_var_assign.py create mode 100644 src/test/data/pa2/sample/expr_var_assign.py.ast create mode 100644 src/test/data/pa2/sample/expr_var_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/func_def_call.py create mode 100644 src/test/data/pa2/sample/func_def_call.py.ast create mode 100644 src/test/data/pa2/sample/func_def_call.py.ast.typed create mode 100644 src/test/data/pa2/sample/stmt_for_lists.py create mode 100644 src/test/data/pa2/sample/stmt_for_lists.py.ast create mode 100644 src/test/data/pa2/sample/stmt_for_lists.py.ast.typed create mode 100644 src/test/data/pa2/sample/stmt_for_strings.py create mode 100644 src/test/data/pa2/sample/stmt_for_strings.py.ast create mode 100644 src/test/data/pa2/sample/stmt_for_strings.py.ast.typed create mode 100644 src/test/data/pa2/sample/stmt_if.py create mode 100644 src/test/data/pa2/sample/stmt_if.py.ast create mode 100644 src/test/data/pa2/sample/stmt_if.py.ast.typed create mode 100644 src/test/data/pa2/sample/stmt_list_assign.py create mode 100644 src/test/data/pa2/sample/stmt_list_assign.py.ast create mode 100644 src/test/data/pa2/sample/stmt_list_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/stmt_var_assign.py create mode 100644 src/test/data/pa2/sample/stmt_var_assign.py.ast create mode 100644 src/test/data/pa2/sample/stmt_var_assign.py.ast.typed create mode 100644 src/test/data/pa2/sample/stmt_while.py create mode 100644 src/test/data/pa2/sample/stmt_while.py.ast create mode 100644 src/test/data/pa2/sample/stmt_while.py.ast.typed create mode 100644 src/test/data/pa2/sample/strings.py create mode 100644 src/test/data/pa2/sample/strings.py.ast create mode 100644 src/test/data/pa2/sample/strings.py.ast.typed create mode 100644 src/test/data/pa2/student_contributed/bad_semantic.py create mode 100644 src/test/data/pa2/student_contributed/bad_types.py create mode 100644 src/test/data/pa2/student_contributed/good.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21cc758 --- /dev/null +++ b/.gitignore @@ -0,0 +1,149 @@ +.DS_Store +__pycache__ +target + +# Created by https://www.gitignore.io/api/java,eclipse,intellij,emacs,vim + +### Java ### +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + + +### Eclipse ### +*.pydevproject +.metadata +.gradle +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Java annotation processor (APT) +.factorypath + +# PDT-specific +.buildpath + +# sbteclipse plugin +.target + +# TeXlipse plugin +.texlipse + + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ + + +### Vim ### +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist +*~ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0808d4b --- /dev/null +++ b/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2017-2018 The Regents of the University of California + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6716c27 --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# NYU Compiler Construction CSCI-GA.2130/Spring 2021: Programming Assignment 2 + +This assignment is adapted from https://github.com/cs164berkeley/pa2-chocopy-semantic-analysis with the authors' permission. + +See the PA2 document on Piazza for a detailed specification. + +## Quickstart + +Run the following commands to compile your analyzer and run the tests: +``` +mvn clean package +java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \ + --pass=.s --test --dir src/test/data/pa2/sample/ +``` + +The dot in `--pass` makes the compiler skip parsing and go straight to semantic analysis. +`--pass=.s` uses your (`s` for `student`) analyzer to perform semantic analysis on a preparsed input (in this case, the `.ast` files under `src/test/data/pa2/sample/`). +With the starter code, only two tests should pass. +Your main objective is to build an analyzer that passes all the provided tests. + +`--pass=.r` uses the reference (`r` for `reference`) analyzer, which should pass all tests. + +In addition to running in test mode with `--test`, you can also observe the actual output of your (or reference) analyzer with: +``` +java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \ + --pass=.s src/test/data/pa2/sample/expr_unary.py.ast +``` + +You can also run both passes on the original `.py` file: +``` +java -cp "chocopy-ref.jar:target/assignment.jar" chocopy.ChocoPy \ + --pass=rr src/test/data/pa2/sample/expr_unary.py +``` + +Once you merge your parser code from assignment 1, you should be able to use `--pass=ss`. diff --git a/chocopy-ref.jar b/chocopy-ref.jar new file mode 100644 index 0000000000000000000000000000000000000000..a497f250c0918754ad6e49ccd25efddcf20f9036 GIT binary patch literal 144775 zcmaI718`cX1sQM%I1msJ7!Z|I7x`$ozxi6NylM}Ksbo6rwGIZ3_lQWGLN||w) z1$>Mr+3YyU-!$r;1@!?ARhgMunYf>-Lyu}r4KBqK%9FfHr%MM!;eWJ+uM8dP4ITt! zog4%N=esS&7WT&W4jv4yrgkn)3~K*zrZ=`RbaKj0cQZg=!W_OK4&aNB;qhNofE4x* zuAmeXK{YT`9wjsAV_(ZA`;ob2>Y9S=1>CMLEHD5D!j*xF);(`;RQ7ByuK3)PcR971 zre02SVohXD7?qGXT!HB_pFkUE6#JnMOM0=LO;4siAIYRE3 zdtAXMD0+hKD0{zxQ&IGU+%fjpf>%(s1>Mp1=z?2OwuRiW_V|LIQTPR4W3nl$BJ~fW%!g`!`6kY+3misa4Pv48 zroI#o=Ek8y57v@>9-{9=*^~7ozto~Z_=_S@JO<{-IfQ?45zD_1z`pM1%AJyaUI+K= z+smC&^f(Ip-8G|y^Z0}AGst06ex3)%?+eIb(`^iow$$&_AajKz>ijHoNbrj3(PN0v z;P;Ezz-l=T#GZ_~h!G^yF?#FI`TL8_tZr>l`$Sxfra%YMNFkr5=I=$oal-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ocopy + chocopy + jar + 2.2-SNAPSHOT + chocopy + http://maven.apache.org + + + + false + + + + + + + + de.jflex + jflex-maven-plugin + 1.6.1 + + + com.github.vbmacher + cup-maven-plugin + 11b-20160615 + + + maven-assembly-plugin + 3.1.0 + + + maven-jar-plugin + 3.1.0 + + + maven-site-plugin + 3.7.1 + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + assignment + false + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + UTF-8 + 1.8 + 1.8 + true + true + + + + + + + src/main/asm + + **/*.s + **/*.os + + + **/reference/*.s + + + + + + + + reference + + + + src/main/java/chocopy/reference/ + + + + + + + maven-jar-plugin + + + **/pa1/* + **/pa2/* + **/pa3/* + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + chocopy-ref + false + + + + + de.jflex + jflex-maven-plugin + + + jflex-reference + + generate + + + + src/main/jflex/chocopy/reference/ChocoPy.jflex + + ${chocopy.debug} + true + + + + + + + com.github.vbmacher + cup-maven-plugin + + + cup-reference + + generate + + + src/main/cup/chocopy/reference/ChocoPy.cup + chocopy.reference + ChocoPyParser + ChocoPyTokens + ${chocopy.debug} + ${chocopy.debug} + ${chocopy.debug} + true + + + + + + + maven-compiler-plugin + + true + none + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.1 + + + copy-dependencies + package + + copy-dependencies + + + + + + + + + + pa1 + + + + src/main/java/chocopy/pa1 + + + + + + + de.jflex + jflex-maven-plugin + + + jflex-pa1 + + generate + + + + src/main/jflex/chocopy/pa1/ChocoPy.jflex + + ${chocopy.debug} + true + + + + + + + com.github.vbmacher + cup-maven-plugin + + + cup-pa1 + + generate + + + src/main/cup/chocopy/pa1/ChocoPy.cup + chocopy.pa1 + ChocoPyParser + ChocoPyTokens + ${chocopy.debug} + ${chocopy.debug} + ${chocopy.debug} + true + + + + + + + + + pa2 + + + + src/main/java/chocopy/pa2 + + + + + pa3 + + + + src/main/java/chocopy/pa3 + + + + + + + + + venus164-repo + Repository for Venus164 + https://raw.githubusercontent.com/chocopy/venus/maven-repository/ + + + + + + net.sourceforge.argparse4j + argparse4j + 0.8.1 + + + com.fasterxml.jackson.core + jackson-databind + [2.9.10.1,) + + + com.fasterxml.jackson.module + jackson-module-parameter-names + 2.9.10 + + + com.github.vbmacher + java-cup-runtime + 11b-20160615 + + + + de.jflex + jflex + 1.6.1 + + + org.jetbrains.kotlin + kotlin-stdlib + 1.2.71 + + + edu.berkeley.eecs.venus164 + venus164 + 0.2.4 + + + junit + junit + 4.12 + test + + + net.sf.proguard + proguard-base + 6.0.3 + + + diff --git a/src/main/java/chocopy/common/Utils.java b/src/main/java/chocopy/common/Utils.java new file mode 100644 index 0000000..aefd409 --- /dev/null +++ b/src/main/java/chocopy/common/Utils.java @@ -0,0 +1,54 @@ +package chocopy.common; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.stream.Collectors; + +/** Utility functions for general use. */ +public class Utils { + + /** + * Return resource file FILENAME's contents as a string. FILENAME can refer to a file within the + * class hierarchy, so that a text resource in file resource.txt in the chocopy.common.codegen + * package, for example, could be referred to with FILENAME chocopy/common/codegen/resource.txt. + * + *

    Credit: Lucio Paiva. + */ + public static String getResourceFileAsString(String fileName) { + InputStream is = Utils.class.getClassLoader().getResourceAsStream(fileName); + if (is != null) { + BufferedReader reader = + new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); + return reader.lines().collect(Collectors.joining(System.lineSeparator())); + } + return null; + } + + /** + * Return an exception signalling a fatal error having a message formed from MSGFORMAT and ARGS, + * as for String.format. + */ + public static Error fatal(String msgFormat, Object... args) { + return new Error(String.format(msgFormat, args)); + } + + /** + * Return the string S padded with FILL to TOLEN characters. Padding is on the left if + * PADONLEFT, and otherwise on the right. If S is already at least TOLEN characters, returns S. + */ + public static String pad(String s, Character fill, int toLen, boolean padOnLeft) { + StringBuilder result = new StringBuilder(toLen); + if (!padOnLeft) { + result.append(s); + } + for (int n = s.length(); n < toLen; n += 1) { + result.append(fill); + } + if (padOnLeft) { + result.append(s); + } + return result.toString(); + } +} diff --git a/src/main/java/chocopy/common/analysis/AbstractNodeAnalyzer.java b/src/main/java/chocopy/common/analysis/AbstractNodeAnalyzer.java new file mode 100644 index 0000000..7225c2b --- /dev/null +++ b/src/main/java/chocopy/common/analysis/AbstractNodeAnalyzer.java @@ -0,0 +1,174 @@ +package chocopy.common.analysis; + +import chocopy.common.astnodes.*; + +/** + * An empty implementation of the {@link NodeAnalyzer} that simply returns does nothing and returns + * null for every AST node type. + * + *

    T is the type of analysis result. + */ +public class AbstractNodeAnalyzer implements NodeAnalyzer { + @Override + public T analyze(AssignStmt node) { + return defaultAction(node); + } + + @Override + public T analyze(BinaryExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(BooleanLiteral node) { + return defaultAction(node); + } + + @Override + public T analyze(CallExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(ClassDef node) { + return defaultAction(node); + } + + @Override + public T analyze(ClassType node) { + return defaultAction(node); + } + + @Override + public T analyze(CompilerError node) { + return defaultAction(node); + } + + @Override + public T analyze(Errors node) { + return defaultAction(node); + } + + @Override + public T analyze(ExprStmt node) { + return defaultAction(node); + } + + @Override + public T analyze(ForStmt node) { + return defaultAction(node); + } + + @Override + public T analyze(FuncDef node) { + return defaultAction(node); + } + + @Override + public T analyze(GlobalDecl node) { + return defaultAction(node); + } + + @Override + public T analyze(Identifier node) { + return defaultAction(node); + } + + @Override + public T analyze(IfExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(IfStmt node) { + return defaultAction(node); + } + + @Override + public T analyze(IndexExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(IntegerLiteral node) { + return defaultAction(node); + } + + @Override + public T analyze(ListExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(ListType node) { + return defaultAction(node); + } + + @Override + public T analyze(MemberExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(MethodCallExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(NoneLiteral node) { + return defaultAction(node); + } + + @Override + public T analyze(NonLocalDecl node) { + return defaultAction(node); + } + + @Override + public T analyze(Program node) { + return defaultAction(node); + } + + @Override + public T analyze(ReturnStmt node) { + return defaultAction(node); + } + + @Override + public T analyze(StringLiteral node) { + return defaultAction(node); + } + + @Override + public T analyze(TypedVar node) { + return defaultAction(node); + } + + @Override + public T analyze(UnaryExpr node) { + return defaultAction(node); + } + + @Override + public T analyze(VarDef node) { + return defaultAction(node); + } + + @Override + public T analyze(WhileStmt node) { + return defaultAction(node); + } + + @Override + public void setDefault(T value) { + defaultValue = value; + } + + @Override + public T defaultAction(Node node) { + return defaultValue; + } + + /** Default value for non-overridden methods. */ + private T defaultValue = null; +} diff --git a/src/main/java/chocopy/common/analysis/NodeAnalyzer.java b/src/main/java/chocopy/common/analysis/NodeAnalyzer.java new file mode 100644 index 0000000..2326fbc --- /dev/null +++ b/src/main/java/chocopy/common/analysis/NodeAnalyzer.java @@ -0,0 +1,93 @@ +package chocopy.common.analysis; + +import chocopy.common.astnodes.*; + +/** + * This interface can be used to separate logic for various concrete classes in the AST class + * hierarchy. + * + *

    The idea is that a phase of the analysis is encapsulated in a class that implements this + * interface, and contains an overriding of the analyze method for each concrete Node class that + * needs something other than default processing. Each concrete node class, C, implements a generic + * dispatch method that takes a NodeAnalyzer argument and calls the overloading of analyze that + * takes an argument of type C. The effect is that anode.dispatch(anAnalyzer) executes the method + * anAnalyzer.analyze that is appropriate to aNode's dynamic type. As a result each NodeAnalyzer + * subtype encapsulates all implementations of a particular action on Nodes. Thus, it inverts the + * usual OO pattern in which the implementations of analysis A for each different class are + * scattered among the class bodies themselves as overridings of a method A on the Node class. + * + *

    The class AbstractNodeAnalyzer provides empty default implementations for these methods. + * + *

    The type T is the type of result returned by the encapsulated analysis. + */ +public interface NodeAnalyzer { + + T analyze(AssignStmt node); + + T analyze(BinaryExpr node); + + T analyze(BooleanLiteral node); + + T analyze(CallExpr node); + + T analyze(ClassDef node); + + T analyze(ClassType node); + + T analyze(CompilerError node); + + T analyze(Errors node); + + T analyze(ExprStmt node); + + T analyze(ForStmt node); + + T analyze(FuncDef node); + + T analyze(GlobalDecl node); + + T analyze(Identifier node); + + T analyze(IfExpr node); + + T analyze(IfStmt node); + + T analyze(IndexExpr node); + + T analyze(IntegerLiteral node); + + T analyze(ListExpr node); + + T analyze(ListType node); + + T analyze(MemberExpr node); + + T analyze(MethodCallExpr node); + + T analyze(NoneLiteral node); + + T analyze(NonLocalDecl node); + + T analyze(Program node); + + T analyze(ReturnStmt node); + + T analyze(StringLiteral node); + + T analyze(TypedVar node); + + T analyze(UnaryExpr node); + + T analyze(VarDef node); + + T analyze(WhileStmt node); + + /** + * Set the default value returned by calls to analyze that are not overridden to VALUE. By + * default, this is null. + */ + void setDefault(T value); + + /** Default value for non-overridden methods. */ + T defaultAction(Node node); +} diff --git a/src/main/java/chocopy/common/analysis/SymbolTable.java b/src/main/java/chocopy/common/analysis/SymbolTable.java new file mode 100644 index 0000000..bc22ac4 --- /dev/null +++ b/src/main/java/chocopy/common/analysis/SymbolTable.java @@ -0,0 +1,62 @@ +package chocopy.common.analysis; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * A block-structured symbol table a mapping identifiers to information about them of type T in a + * given declarative region. + */ +public class SymbolTable { + + /** Contents of the current (innermost) region. */ + private final Map tab = new HashMap<>(); + /** Enclosing block. */ + private final SymbolTable parent; + + /** A table representing a region nested in that represented by PARENT0. */ + public SymbolTable(SymbolTable parent0) { + parent = parent0; + } + + /** A top-level symbol table. */ + public SymbolTable() { + this.parent = null; + } + + /** Returns the mapping of NAME in the innermost nested region containing this one. */ + public T get(String name) { + if (tab.containsKey(name)) { + return tab.get(name); + } else if (parent != null) { + return parent.get(name); + } else { + return null; + } + } + + /** + * Adds a new mapping of NAME -> VALUE to the current region, possibly shadowing mappings in the + * enclosing parent. Returns modified table. + */ + public SymbolTable put(String name, T value) { + tab.put(name, value); + return this; + } + + /** Returns whether NAME has a mapping in this region (ignoring enclosing regions. */ + public boolean declares(String name) { + return tab.containsKey(name); + } + + /** Returns all the names declared this region (ignoring enclosing regions). */ + public Set getDeclaredSymbols() { + return tab.keySet(); + } + + /** Returns the parent, or null if this is the top level. */ + public SymbolTable getParent() { + return this.parent; + } +} diff --git a/src/main/java/chocopy/common/analysis/types/ClassValueType.java b/src/main/java/chocopy/common/analysis/types/ClassValueType.java new file mode 100644 index 0000000..05c2e93 --- /dev/null +++ b/src/main/java/chocopy/common/analysis/types/ClassValueType.java @@ -0,0 +1,53 @@ +package chocopy.common.analysis.types; + +import chocopy.common.astnodes.ClassType; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; + +/** Represents the semantic value of a simple class reference. */ +public class ClassValueType extends ValueType { + + /** The name of the class. */ + private final String className; + + /** A class type for the class named CLASSNAME. */ + @JsonCreator + public ClassValueType(@JsonProperty String className) { + this.className = className; + } + + /** A class type for the class referenced by CLASSTYPEANNOTATION. */ + public ClassValueType(ClassType classTypeAnnotation) { + this.className = classTypeAnnotation.className; + } + + @Override + @JsonProperty + public String className() { + return className; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassValueType classType = (ClassValueType) o; + return Objects.equals(className, classType.className); + } + + @Override + public int hashCode() { + return Objects.hash(className); + } + + @Override + public String toString() { + return className; + } +} diff --git a/src/main/java/chocopy/common/analysis/types/FuncType.java b/src/main/java/chocopy/common/analysis/types/FuncType.java new file mode 100644 index 0000000..69fdefc --- /dev/null +++ b/src/main/java/chocopy/common/analysis/types/FuncType.java @@ -0,0 +1,45 @@ +package chocopy.common.analysis.types; + +import com.fasterxml.jackson.annotation.JsonCreator; + +import java.util.ArrayList; +import java.util.List; + +/** Semantic information for a function or method. */ +public class FuncType extends Type { + + /** Types of parameters. */ + public final List parameters; + /** Function's return type. */ + public final ValueType returnType; + + /** Create a FuncType returning RETURNTYPE0, initially parameterless. */ + public FuncType(ValueType returnType0) { + this(new ArrayList<>(), returnType0); + } + + /** + * Create a FuncType for NAME0 with formal parameter types PARAMETERS0, returning type + * RETURNTYPE0. + */ + @JsonCreator + public FuncType(List parameters0, ValueType returnType0) { + this.parameters = parameters0; + this.returnType = returnType0; + } + + @Override + public boolean isFuncType() { + return true; + } + + /** Return the type of the K-th parameter. */ + public ValueType getParamType(int k) { + return parameters.get(k); + } + + @Override + public String toString() { + return ""; + } +} diff --git a/src/main/java/chocopy/common/analysis/types/ListValueType.java b/src/main/java/chocopy/common/analysis/types/ListValueType.java new file mode 100644 index 0000000..fae59c7 --- /dev/null +++ b/src/main/java/chocopy/common/analysis/types/ListValueType.java @@ -0,0 +1,57 @@ +package chocopy.common.analysis.types; + +import chocopy.common.astnodes.ListType; +import com.fasterxml.jackson.annotation.JsonCreator; + +import java.util.Objects; + +/** Represents a semantic value of a list type denotation. */ +public class ListValueType extends ValueType { + + /** This ListValueType represents [ELEMENTTYPE]. */ + public final ValueType elementType; + + /** Represents [ELEMENTTYPE]. */ + @JsonCreator + public ListValueType(Type elementType) { + this.elementType = (ValueType) elementType; + } + + /** Represents [], where is that denoted in TYPEANNOTATION. */ + public ListValueType(ListType typeAnnotation) { + elementType = ValueType.annotationToValueType(typeAnnotation.elementType); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListValueType listType = (ListValueType) o; + return Objects.equals(elementType, listType.elementType); + } + + @Override + public int hashCode() { + return Objects.hash(elementType); + } + + @Override + public String toString() { + return "[" + elementType.toString() + "]"; + } + + /** Returns true iff I represent [T]. */ + @Override + public boolean isListType() { + return true; + } + + @Override + public ValueType elementType() { + return elementType; + } +} diff --git a/src/main/java/chocopy/common/analysis/types/Type.java b/src/main/java/chocopy/common/analysis/types/Type.java new file mode 100644 index 0000000..2eddc37 --- /dev/null +++ b/src/main/java/chocopy/common/analysis/types/Type.java @@ -0,0 +1,68 @@ +package chocopy.common.analysis.types; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * Representation for the static type of symbols and expressions during type-checking. + * + *

    Symbols such as variables and attributes will typically map to a {@link ValueType}. + * + *

    Symbols such as classes will typically map to a more complex Type. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonSubTypes({ + @JsonSubTypes.Type(FuncType.class), + @JsonSubTypes.Type(ClassValueType.class), + @JsonSubTypes.Type(ListValueType.class) +}) +public abstract class Type { + + /** The type object. */ + public static final ClassValueType OBJECT_TYPE = new ClassValueType("object"); + /** The type int. */ + public static final ClassValueType INT_TYPE = new ClassValueType("int"); + /** The type str. */ + public static final ClassValueType STR_TYPE = new ClassValueType("str"); + /** The type bool. */ + public static final ClassValueType BOOL_TYPE = new ClassValueType("bool"); + + /** The type of None. */ + public static final ClassValueType NONE_TYPE = new ClassValueType(""); + /** The type of []. */ + public static final ClassValueType EMPTY_TYPE = new ClassValueType(""); + + /** Returns the name of the class, if this is a class type, Otherwise null. */ + public String className() { + return null; + } + + /** Return true iff this is a type that does not include the value None. */ + @JsonIgnore + public boolean isSpecialType() { + return equals(INT_TYPE) || equals(BOOL_TYPE) || equals(STR_TYPE); + } + + @JsonIgnore + public boolean isListType() { + return false; + } + + @JsonIgnore + public boolean isFuncType() { + return false; + } + + /** Return true iff this type represents a kind of assignable value. */ + @JsonIgnore + public boolean isValueType() { + return false; + } + + /** For list types, return the type of the elements; otherwise null. */ + @JsonIgnore + public ValueType elementType() { + return null; + } +} diff --git a/src/main/java/chocopy/common/analysis/types/ValueType.java b/src/main/java/chocopy/common/analysis/types/ValueType.java new file mode 100644 index 0000000..bb5d908 --- /dev/null +++ b/src/main/java/chocopy/common/analysis/types/ValueType.java @@ -0,0 +1,29 @@ +package chocopy.common.analysis.types; + +import chocopy.common.astnodes.ClassType; +import chocopy.common.astnodes.ListType; +import chocopy.common.astnodes.TypeAnnotation; + +/** + * A ValueType references types that are assigned to variables and expressions. + * + *

    In particular, ValueType can be a {@link ClassValueType} (e.g. "int") or a {@link + * ListValueType} (e.g. "[int]"). + */ +public abstract class ValueType extends Type { + + /** Returns the type corresponding to ANNOTATION. */ + public static ValueType annotationToValueType(TypeAnnotation annotation) { + if (annotation instanceof ClassType) { + return new ClassValueType((ClassType) annotation); + } else { + assert annotation instanceof ListType; + return new ListValueType((ListType) annotation); + } + } + + @Override + public boolean isValueType() { + return true; + } +} diff --git a/src/main/java/chocopy/common/astnodes/AssignStmt.java b/src/main/java/chocopy/common/astnodes/AssignStmt.java new file mode 100644 index 0000000..1452463 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/AssignStmt.java @@ -0,0 +1,25 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** Single and multiple assignments. */ +public class AssignStmt extends Stmt { + /** List of left-hand sides. */ + public final List targets; + /** Right-hand-side value to be assigned. */ + public final Expr value; + + /** AST for TARGETS[0] = TARGETS[1] = ... = VALUE spanning source locations [LEFT..RIGHT]. */ + public AssignStmt(Location left, Location right, List targets, Expr value) { + super(left, right); + this.targets = targets; + this.value = value; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/BinaryExpr.java b/src/main/java/chocopy/common/astnodes/BinaryExpr.java new file mode 100644 index 0000000..f4ce05b --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/BinaryExpr.java @@ -0,0 +1,31 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** . */ +public class BinaryExpr extends Expr { + + /** Left operand. */ + public final Expr left; + /** Operator name. */ + public final String operator; + /** Right operand. */ + public final Expr right; + + /** + * An AST for expressions of the form LEFTEXPR OP RIGHTEXPR from text in range + * [LEFTLOC..RIGHTLOC]. + */ + public BinaryExpr( + Location leftLoc, Location rightLoc, Expr leftExpr, String op, Expr rightExpr) { + super(leftLoc, rightLoc); + left = leftExpr; + operator = op; + right = rightExpr; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/BooleanLiteral.java b/src/main/java/chocopy/common/astnodes/BooleanLiteral.java new file mode 100644 index 0000000..ffce126 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/BooleanLiteral.java @@ -0,0 +1,21 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Literals True or False. */ +public final class BooleanLiteral extends Literal { + + /** True iff I represent True. */ + public final boolean value; + + /** An AST for the token True or False at [LEFT..RIGHT], depending on VALUE. */ + public BooleanLiteral(Location left, Location right, boolean value) { + super(left, right); + this.value = value; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/CallExpr.java b/src/main/java/chocopy/common/astnodes/CallExpr.java new file mode 100644 index 0000000..84f13ae --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/CallExpr.java @@ -0,0 +1,26 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** A function call. */ +public class CallExpr extends Expr { + + /** The called function. */ + public final Identifier function; + /** The actual parameter expressions. */ + public final List args; + + /** AST for FUNCTION(ARGS) at [LEFT..RIGHT]. */ + public CallExpr(Location left, Location right, Identifier function, List args) { + super(left, right); + this.function = function; + this.args = args; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/ClassDef.java b/src/main/java/chocopy/common/astnodes/ClassDef.java new file mode 100644 index 0000000..63531c8 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/ClassDef.java @@ -0,0 +1,39 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** A class definition. */ +public class ClassDef extends Declaration { + + /** Name of the declared class. */ + public final Identifier name; + /** Name of the parent class. */ + public final Identifier superClass; + /** Body of the class. */ + public final List declarations; + + /** An AST for class NAME(SUPERCLASS): DECLARATIONS. spanning source locations [LEFT..RIGHT]. */ + public ClassDef( + Location left, + Location right, + Identifier name, + Identifier superClass, + List declarations) { + super(left, right); + this.name = name; + this.superClass = superClass; + this.declarations = declarations; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } + + @Override + public Identifier getIdentifier() { + return this.name; + } +} diff --git a/src/main/java/chocopy/common/astnodes/ClassType.java b/src/main/java/chocopy/common/astnodes/ClassType.java new file mode 100644 index 0000000..fd4cd4d --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/ClassType.java @@ -0,0 +1,21 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** A simple class type name. */ +public final class ClassType extends TypeAnnotation { + + /** The denotation of the class in source. */ + public final String className; + + /** An AST denoting a type named CLASSNAME0 at [LEFT..RIGHT]. */ + public ClassType(Location left, Location right, String className0) { + super(left, right); + className = className0; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/CompilerError.java b/src/main/java/chocopy/common/astnodes/CompilerError.java new file mode 100644 index 0000000..81cc5bb --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/CompilerError.java @@ -0,0 +1,56 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import com.fasterxml.jackson.annotation.JsonInclude; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.Arrays; +import java.util.Objects; + +/** Represents a single error. Does not correspond to any Python source construct. */ +public class CompilerError extends Node { + + /** + * Represents an error with message MESSAGE. Iff SYNTAX, it is a syntactic error. The error + * applies to source text at [LEFT..RIGHT]. + */ + public CompilerError(Location left, Location right, String message, boolean syntax) { + super(left, right); + this.message = message; + this.syntax = syntax; + } + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + public boolean isSyntax() { + return syntax; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CompilerError that = (CompilerError) o; + return Objects.equals(message, that.message) + && Arrays.equals(getLocation(), that.getLocation()); + } + + @Override + public int hashCode() { + int result = Objects.hash(message); + result = 31 * result + Arrays.hashCode(getLocation()); + return result; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } + + /** The error message. */ + public final String message; + /** True if this is a syntax error. */ + private final boolean syntax; +} diff --git a/src/main/java/chocopy/common/astnodes/Declaration.java b/src/main/java/chocopy/common/astnodes/Declaration.java new file mode 100644 index 0000000..0faa921 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Declaration.java @@ -0,0 +1,17 @@ +package chocopy.common.astnodes; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Base of all AST nodes representing definitions or declarations. */ +public abstract class Declaration extends Node { + + /** A definition or declaration spanning source locations [LEFT..RIGHT]. */ + public Declaration(Location left, Location right) { + super(left, right); + } + + /** Return the identifier defined by this Declaration. */ + @JsonIgnore + public abstract Identifier getIdentifier(); +} diff --git a/src/main/java/chocopy/common/astnodes/Errors.java b/src/main/java/chocopy/common/astnodes/Errors.java new file mode 100644 index 0000000..86240dd --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Errors.java @@ -0,0 +1,71 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** Collects the error messages in a Program. There is exactly one per Program node. */ +public class Errors extends Node { + + /** The accumulated error messages in the order added. */ + public final List errors; + + /** True iff multiple semantic errors allowed on a node. */ + @JsonIgnore private boolean allowMultipleErrors; + + /** + * An Errors whose list of CompilerErrors is ERRORS. The list should be modified using this.add. + */ + @JsonCreator + public Errors(List errors) { + super(null, null); + this.errors = errors; + allowMultipleErrors = true; + } + + /** Return true iff there are any errors. */ + public boolean hasErrors() { + return !this.errors.isEmpty(); + } + + /** Prevent multiple semantic errors on the same node. */ + public void suppressMultipleErrors() { + allowMultipleErrors = false; + } + + /** + * Add a new semantic error message attributed to NODE, with message String.format(MESSAGEFORM, + * ARGS). + */ + public void semError(Node node, String messageForm, Object... args) { + if (allowMultipleErrors || !node.hasError()) { + String msg = String.format(messageForm, args); + CompilerError err = new CompilerError(null, null, msg, false); + err.setLocation(node.getLocation()); + add(err); + if (!node.hasError()) { + node.setErrorMsg(msg); + } + } + } + + /** + * Add a new syntax error message attributed to the source text between LEFT and RIGHT, and with + * message String.format(MESSAGEFORM, ARGS). + */ + public void syntaxError(Location left, Location right, String messageForm, Object... args) { + add(new CompilerError(left, right, String.format(messageForm, args), true)); + } + + /** Add ERR to the list of errors. */ + public void add(CompilerError err) { + errors.add(err); + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/Expr.java b/src/main/java/chocopy/common/astnodes/Expr.java new file mode 100644 index 0000000..7372d58 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Expr.java @@ -0,0 +1,43 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.types.Type; +import com.fasterxml.jackson.annotation.JsonInclude; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** + * Base of all AST nodes representing expressions. + * + *

    There is nothing in this class, but there will be many AST node types that have fields that + * are *any expression*. For those cases, having a field of this type will encompass all types of + * expressions such as binary expressions and literals that subclass this class. + */ +public abstract class Expr extends Node { + + /** A Python expression spanning source locations [LEFT..RIGHT]. */ + public Expr(Location left, Location right) { + super(left, right); + } + + /** + * The type of the value that this expression evaluates to. + * + *

    This field is always null after the parsing stage, but is populated by the + * typechecker in the semantic analysis stage. + * + *

    After typechecking this field may be null only for expressions that cannot be + * assigned a type. In particular, {@link NoneLiteral} expressions will not have a typed + * assigned to them. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private Type inferredType; + + /** Set getInferredType() to TYPE, returning TYPE. */ + public Type setInferredType(Type type) { + inferredType = type; + return type; + } + + public Type getInferredType() { + return inferredType; + } +} diff --git a/src/main/java/chocopy/common/astnodes/ExprStmt.java b/src/main/java/chocopy/common/astnodes/ExprStmt.java new file mode 100644 index 0000000..5b921a0 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/ExprStmt.java @@ -0,0 +1,21 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Statements consisting of expressions. */ +public final class ExprStmt extends Stmt { + + /** The expression I evaluate. */ + public final Expr expr; + + /** The AST for EXPR spanning source locations [LEFT..RIGHT] in a statement context. */ + public ExprStmt(Location left, Location right, Expr expr) { + super(left, right); + this.expr = expr; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/ForStmt.java b/src/main/java/chocopy/common/astnodes/ForStmt.java new file mode 100644 index 0000000..019b2d8 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/ForStmt.java @@ -0,0 +1,29 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** For statements. */ +public class ForStmt extends Stmt { + /** Control variable. */ + public final Identifier identifier; + /** Source of values of control statement. */ + public final Expr iterable; + /** Repeated statements. */ + public final List body; + + /** The AST for for IDENTIFIER in ITERABLE: BODY spanning source locations [LEFT..RIGHT]. */ + public ForStmt( + Location left, Location right, Identifier identifier, Expr iterable, List body) { + super(left, right); + this.identifier = identifier; + this.iterable = iterable; + this.body = body; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/FuncDef.java b/src/main/java/chocopy/common/astnodes/FuncDef.java new file mode 100644 index 0000000..b3ca0f2 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/FuncDef.java @@ -0,0 +1,50 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** Def statements. */ +public class FuncDef extends Declaration { + + /** Defined name. */ + public final Identifier name; + /** Formal parameters. */ + public final List params; + /** Return type annotation. */ + public final TypeAnnotation returnType; + /** Local-variable,inner-function, global, and nonlocal declarations. */ + public final List declarations; + /** Other statements. */ + public final List statements; + + /** + * The AST for def NAME(PARAMS) -> RETURNTYPE: DECLARATIONS STATEMENTS spanning source locations + * [LEFT..RIGHT]. + */ + public FuncDef( + Location left, + Location right, + Identifier name, + List params, + TypeAnnotation returnType, + List declarations, + List statements) { + super(left, right); + this.name = name; + this.params = params; + this.returnType = returnType; + this.declarations = declarations; + this.statements = statements; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } + + @Override + public Identifier getIdentifier() { + return this.name; + } +} diff --git a/src/main/java/chocopy/common/astnodes/GlobalDecl.java b/src/main/java/chocopy/common/astnodes/GlobalDecl.java new file mode 100644 index 0000000..b347d4d --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/GlobalDecl.java @@ -0,0 +1,26 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Declaration of global variable. */ +public class GlobalDecl extends Declaration { + + /** The declared variable. */ + public final Identifier variable; + + /** The AST for the declaration global VARIABLE spanning source locations [LEFT..RIGHT]. */ + public GlobalDecl(Location left, Location right, Identifier variable) { + super(left, right); + this.variable = variable; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } + + @Override + public Identifier getIdentifier() { + return this.variable; + } +} diff --git a/src/main/java/chocopy/common/astnodes/Identifier.java b/src/main/java/chocopy/common/astnodes/Identifier.java new file mode 100644 index 0000000..7593126 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Identifier.java @@ -0,0 +1,24 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** A simple identifier. */ +public class Identifier extends Expr { + + /** Text of the identifier. */ + public final String name; + + /** + * An AST for the variable, method, or parameter named NAME, spanning source locations + * [LEFT..RIGHT]. + */ + public Identifier(Location left, Location right, String name) { + super(left, right); + this.name = name; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/IfExpr.java b/src/main/java/chocopy/common/astnodes/IfExpr.java new file mode 100644 index 0000000..3d3d809 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/IfExpr.java @@ -0,0 +1,26 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Conditional expressions. */ +public class IfExpr extends Expr { + /** Boolean condition. */ + public final Expr condition; + /** True branch. */ + public final Expr thenExpr; + /** False branch. */ + public final Expr elseExpr; + + /** The AST for THENEXPR if CONDITION else ELSEEXPR spanning source locations [LEFT..RIGHT]. */ + public IfExpr(Location left, Location right, Expr condition, Expr thenExpr, Expr elseExpr) { + super(left, right); + this.condition = condition; + this.thenExpr = thenExpr; + this.elseExpr = elseExpr; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/IfStmt.java b/src/main/java/chocopy/common/astnodes/IfStmt.java new file mode 100644 index 0000000..185b8a1 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/IfStmt.java @@ -0,0 +1,35 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** Conditional statement. */ +public class IfStmt extends Stmt { + /** Test condition. */ + public final Expr condition; + /** "True" branch. */ + public final List thenBody; + /** "False" branch. */ + public final List elseBody; + + /** + * The AST for if CONDITION: THENBODY else: ELSEBODY spanning source locations [LEFT..RIGHT]. + */ + public IfStmt( + Location left, + Location right, + Expr condition, + List thenBody, + List elseBody) { + super(left, right); + this.condition = condition; + this.thenBody = thenBody; + this.elseBody = elseBody; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/IndexExpr.java b/src/main/java/chocopy/common/astnodes/IndexExpr.java new file mode 100644 index 0000000..ce788fa --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/IndexExpr.java @@ -0,0 +1,24 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** List-indexing expression. */ +public class IndexExpr extends Expr { + + /** Indexed list. */ + public final Expr list; + /** Expression for index value. */ + public final Expr index; + + /** The AST for LIST[INDEX]. spanning source locations [LEFT..RIGHT]. */ + public IndexExpr(Location left, Location right, Expr list, Expr index) { + super(left, right); + this.list = list; + this.index = index; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/IntegerLiteral.java b/src/main/java/chocopy/common/astnodes/IntegerLiteral.java new file mode 100644 index 0000000..f2d165b --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/IntegerLiteral.java @@ -0,0 +1,21 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Integer numerals. */ +public final class IntegerLiteral extends Literal { + + /** Value denoted. */ + public final int value; + + /** The AST for the literal VALUE, spanning source locations [LEFT..RIGHT]. */ + public IntegerLiteral(Location left, Location right, int value) { + super(left, right); + this.value = value; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/ListExpr.java b/src/main/java/chocopy/common/astnodes/ListExpr.java new file mode 100644 index 0000000..eab6045 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/ListExpr.java @@ -0,0 +1,23 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** List displays. */ +public final class ListExpr extends Expr { + + /** List of element expressions. */ + public final List elements; + + /** The AST for [ ELEMENTS ]. spanning source locations [LEFT..RIGHT]. */ + public ListExpr(Location left, Location right, List elements) { + super(left, right); + this.elements = elements; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/ListType.java b/src/main/java/chocopy/common/astnodes/ListType.java new file mode 100644 index 0000000..32782ad --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/ListType.java @@ -0,0 +1,21 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Type denotation for a list type. */ +public final class ListType extends TypeAnnotation { + + /** The element of list element. */ + public final TypeAnnotation elementType; + + /** The AST for the type annotation [ ELEMENTTYPE ]. spanning source locations [LEFT..RIGHT]. */ + public ListType(Location left, Location right, TypeAnnotation elementType) { + super(left, right); + this.elementType = elementType; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/Literal.java b/src/main/java/chocopy/common/astnodes/Literal.java new file mode 100644 index 0000000..2afd1be --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Literal.java @@ -0,0 +1,16 @@ +package chocopy.common.astnodes; + +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** + * Base of all the literal nodes. + * + *

    There is nothing in this class, but it is useful to isolate expressions that are constant + * literals. + */ +public abstract class Literal extends Expr { + /** A literal spanning source locations [LEFT..RIGHT]. */ + public Literal(Location left, Location right) { + super(left, right); + } +} diff --git a/src/main/java/chocopy/common/astnodes/MemberExpr.java b/src/main/java/chocopy/common/astnodes/MemberExpr.java new file mode 100644 index 0000000..a9e0a4f --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/MemberExpr.java @@ -0,0 +1,24 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Attribute accessor. */ +public class MemberExpr extends Expr { + + /** Object selected from. */ + public final Expr object; + /** Name of attribute (instance variable or method). */ + public final Identifier member; + + /** The AST for OBJECT.MEMBER. spanning source locations [LEFT..RIGHT]. */ + public MemberExpr(Location left, Location right, Expr object, Identifier member) { + super(left, right); + this.object = object; + this.member = member; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/MethodCallExpr.java b/src/main/java/chocopy/common/astnodes/MethodCallExpr.java new file mode 100644 index 0000000..ab3f424 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/MethodCallExpr.java @@ -0,0 +1,26 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** Method calls. */ +public class MethodCallExpr extends Expr { + + /** Expression for the bound method to be called. */ + public final MemberExpr method; + /** Actual parameters. */ + public final List args; + + /** The AST for METHOD(ARGS). spanning source locations [LEFT..RIGHT]. */ + public MethodCallExpr(Location left, Location right, MemberExpr method, List args) { + super(left, right); + this.method = method; + this.args = args; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/Node.java b/src/main/java/chocopy/common/astnodes/Node.java new file mode 100644 index 0000000..c95f3d6 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Node.java @@ -0,0 +1,176 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.io.IOException; + +/** + * Root of the AST class hierarchy. Every node has a left and right location, indicating the start + * and end of the represented construct in the source text. + * + *

    Every node can be marked with an error message, which serves two purposes: 1. It indicates + * that an error message has been issued for this Node, allowing tne program to reduce cascades of + * error messages. 2. It aids in debugging by making it convenient to see which Nodes have caused an + * error. + */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "kind") +/* List of all concrete subclasses of Node. */ +@JsonSubTypes({ + @JsonSubTypes.Type(AssignStmt.class), + @JsonSubTypes.Type(BinaryExpr.class), + @JsonSubTypes.Type(BooleanLiteral.class), + @JsonSubTypes.Type(CallExpr.class), + @JsonSubTypes.Type(ClassDef.class), + @JsonSubTypes.Type(ClassType.class), + @JsonSubTypes.Type(CompilerError.class), + @JsonSubTypes.Type(Errors.class), + @JsonSubTypes.Type(ExprStmt.class), + @JsonSubTypes.Type(ForStmt.class), + @JsonSubTypes.Type(FuncDef.class), + @JsonSubTypes.Type(GlobalDecl.class), + @JsonSubTypes.Type(Identifier.class), + @JsonSubTypes.Type(IfExpr.class), + @JsonSubTypes.Type(IfStmt.class), + @JsonSubTypes.Type(IndexExpr.class), + @JsonSubTypes.Type(IntegerLiteral.class), + @JsonSubTypes.Type(ListExpr.class), + @JsonSubTypes.Type(ListType.class), + @JsonSubTypes.Type(MemberExpr.class), + @JsonSubTypes.Type(MethodCallExpr.class), + @JsonSubTypes.Type(NoneLiteral.class), + @JsonSubTypes.Type(NonLocalDecl.class), + @JsonSubTypes.Type(Program.class), + @JsonSubTypes.Type(ReturnStmt.class), + @JsonSubTypes.Type(StringLiteral.class), + @JsonSubTypes.Type(TypedVar.class), + @JsonSubTypes.Type(UnaryExpr.class), + @JsonSubTypes.Type(VarDef.class), + @JsonSubTypes.Type(WhileStmt.class), +}) +public abstract class Node { + + /** Node-type indicator for JSON form. */ + public final String kind; + + /** + * Source position information: 0: line number of start, 1: column number of start, 2: line + * number of end, 3: column number of end. + */ + private final int[] location = new int[4]; + + /** + * First error message "blamed" on this Node. When non-null, indicates that an error has been + * found in this Node. + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private String errorMsg; + + /** A Node corresponding to source text between LEFT and RIGHT. */ + public Node(Location left, Location right) { + if (left != null) { + location[0] = left.getLine(); + location[1] = left.getColumn(); + } + if (right != null) { + location[2] = right.getLine(); + location[3] = right.getColumn(); + } + this.kind = getClass().getSimpleName(); + this.errorMsg = null; + } + + /** + * Return my source location as { , , , }. + * Result should not be modified, and contents will change after setLocation(). + */ + public int[] getLocation() { + return location; + } + + /** Copy LOCATION as getLocation(). */ + public void setLocation(final int[] location) { + System.arraycopy(location, 0, this.location, 0, 4); + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String msg) { + this.errorMsg = msg; + } + + /** Return true iff I have been marked with an error message. */ + @JsonIgnore + public boolean hasError() { + return this.errorMsg != null; + } + + /** + * Invoke ANALYZER on me as a node of static type T. See the comment on NodeAnalyzer. Returns + * modified Node. + */ + public abstract T dispatch(NodeAnalyzer analyzer); + + /** Print out the AST in JSON format. */ + @Override + public String toString() { + try { + return toJSON(); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + /** Return a serialization of this node in JSON format. */ + public String toJSON() throws JsonProcessingException { + return mapper.writeValueAsString(this); + } + + /** Mapper to-and-from serialized JSON. */ + private static final ObjectMapper mapper = new ObjectMapper(); + + static { + mapper.enable(SerializationFeature.INDENT_OUTPUT); + mapper.registerModule(new ParameterNamesModule()); + } + + /** Returns a T from JSON, a JSON-serialized T value with class CLAS. */ + public static T fromJSON(String json, Class clas) throws IOException { + return mapper.readValue(json, clas); + } + + /** + * Returns the result of converting JSON, a JSon-serialization of a Node value, into the value + * it serializes. + */ + public static Node fromJSON(String json) throws IOException { + return fromJSON(json, Node.class); + } + + /** + * Returns the result of converting TREE to the value of type T that it represents, where CLAS + * reflects T. + */ + public static T fromJSON(JsonNode tree, Class clas) throws IOException { + return mapper.treeToValue(tree, clas); + } + + /** Returns the translation of serialized value SRC into the corresponding JSON tree. */ + public static JsonNode readTree(String src) throws IOException { + return mapper.readTree(src); + } +} diff --git a/src/main/java/chocopy/common/astnodes/NonLocalDecl.java b/src/main/java/chocopy/common/astnodes/NonLocalDecl.java new file mode 100644 index 0000000..ebaf78d --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/NonLocalDecl.java @@ -0,0 +1,26 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Nonlocal declaration. */ +public class NonLocalDecl extends Declaration { + + /** Name of identifier being declared. */ + public final Identifier variable; + + /** The AST for nonlocal VARIABLE spanning source locations [LEFT..RIGHT]. */ + public NonLocalDecl(Location left, Location right, Identifier variable) { + super(left, right); + this.variable = variable; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } + + @Override + public Identifier getIdentifier() { + return this.variable; + } +} diff --git a/src/main/java/chocopy/common/astnodes/NoneLiteral.java b/src/main/java/chocopy/common/astnodes/NoneLiteral.java new file mode 100644 index 0000000..b51a581 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/NoneLiteral.java @@ -0,0 +1,17 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** The expression 'None'. */ +public final class NoneLiteral extends Literal { + + /** The AST for None, spanning source locations [LEFT..RIGHT]. */ + public NoneLiteral(Location left, Location right) { + super(left, right); + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/Program.java b/src/main/java/chocopy/common/astnodes/Program.java new file mode 100644 index 0000000..e95b2e7 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Program.java @@ -0,0 +1,56 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.ArrayList; +import java.util.List; + +/** An entire Chocopy program. */ +public class Program extends Node { + + /** Initial variable, class, and function declarations. */ + public final List declarations; + /** Trailing statements. */ + public final List statements; + /** Accumulated errors. */ + public final Errors errors; + + /** + * The AST for the program DECLARATIONS STATEMENTS spanning source locations [LEFT..RIGHT]. + * + *

    ERRORS is the container for all error messages applying to the program. + */ + public Program( + Location left, + Location right, + List declarations, + List statements, + Errors errors) { + super(left, right); + this.declarations = declarations; + this.statements = statements; + if (errors == null) { + this.errors = new Errors(new ArrayList<>()); + } else { + this.errors = errors; + } + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } + + /** Returns true iff there is at least one error in the program. */ + @JsonIgnore + public boolean hasErrors() { + return errors.hasErrors(); + } + + /** A convenience method returning the list of all CompilerErrors for this program. */ + @JsonIgnore + public List getErrorList() { + return errors.errors; + } +} diff --git a/src/main/java/chocopy/common/astnodes/ReturnStmt.java b/src/main/java/chocopy/common/astnodes/ReturnStmt.java new file mode 100644 index 0000000..e665042 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/ReturnStmt.java @@ -0,0 +1,21 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Return from function. */ +public class ReturnStmt extends Stmt { + + /** Returned value. */ + public final Expr value; + + /** The AST for return VALUE spanning source locations [LEFT..RIGHT]. */ + public ReturnStmt(Location left, Location right, Expr value) { + super(left, right); + this.value = value; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/Stmt.java b/src/main/java/chocopy/common/astnodes/Stmt.java new file mode 100644 index 0000000..b87780e --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/Stmt.java @@ -0,0 +1,18 @@ +package chocopy.common.astnodes; + +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** + * Base of all AST nodes representing statements. + * + *

    There is nothing in this class, but there will be some AST node types that have fields that + * are *any statement* or a list of statements. For those cases, having a field of this type will + * encompass all types of statements such as expression statements, if statements, while statements, + * etc. + */ +public abstract class Stmt extends Node { + /** A statement spanning source locations [LEFT..RIGHT]. */ + public Stmt(Location left, Location right) { + super(left, right); + } +} diff --git a/src/main/java/chocopy/common/astnodes/StringLiteral.java b/src/main/java/chocopy/common/astnodes/StringLiteral.java new file mode 100644 index 0000000..0eaf928 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/StringLiteral.java @@ -0,0 +1,21 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** String constants. */ +public final class StringLiteral extends Literal { + + /** Contents of the literal, not including quotation marks. */ + public final String value; + + /** The AST for a string literal containing VALUE, spanning source locations [LEFT..RIGHT]. */ + public StringLiteral(Location left, Location right, String value) { + super(left, right); + this.value = value; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/TypeAnnotation.java b/src/main/java/chocopy/common/astnodes/TypeAnnotation.java new file mode 100644 index 0000000..d90b59e --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/TypeAnnotation.java @@ -0,0 +1,11 @@ +package chocopy.common.astnodes; + +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** Base of all AST nodes representing type annotations (list or class types. */ +public abstract class TypeAnnotation extends Node { + /** An annotation spanning source locations [LEFT..RIGHT]. */ + public TypeAnnotation(Location left, Location right) { + super(left, right); + } +} diff --git a/src/main/java/chocopy/common/astnodes/TypedVar.java b/src/main/java/chocopy/common/astnodes/TypedVar.java new file mode 100644 index 0000000..98aae43 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/TypedVar.java @@ -0,0 +1,24 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** An identifier with attached type annotation. */ +public class TypedVar extends Node { + + /** The typed identifier. */ + public final Identifier identifier; + /** The declared type. */ + public final TypeAnnotation type; + + /** The AST for IDENTIFIER : TYPE. spanning source locations [LEFT..RIGHT]. */ + public TypedVar(Location left, Location right, Identifier identifier, TypeAnnotation type) { + super(left, right); + this.identifier = identifier; + this.type = type; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/UnaryExpr.java b/src/main/java/chocopy/common/astnodes/UnaryExpr.java new file mode 100644 index 0000000..199e701 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/UnaryExpr.java @@ -0,0 +1,24 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** An expression applying a unary operator. */ +public class UnaryExpr extends Expr { + + /** The text representation of the operator. */ + public final String operator; + /** The operand to which it is applied. */ + public final Expr operand; + + /** The AST for OPERATOR OPERAND spanning source locations [LEFT..RIGHT]. */ + public UnaryExpr(Location left, Location right, String operator, Expr operand) { + super(left, right); + this.operator = operator; + this.operand = operand; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/common/astnodes/VarDef.java b/src/main/java/chocopy/common/astnodes/VarDef.java new file mode 100644 index 0000000..61d261a --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/VarDef.java @@ -0,0 +1,32 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +/** A declaration of a variable (i.e., with type annotation). */ +public class VarDef extends Declaration { + /** The variable and its assigned type. */ + public final TypedVar var; + /** The initial value assigned. */ + public final Literal value; + + /** + * The AST for VAR = VALUE where VAR has a type annotation, and spanning source locations + * [LEFT..RIGHT]. + */ + public VarDef(Location left, Location right, TypedVar var, Literal value) { + super(left, right); + this.var = var; + this.value = value; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } + + /** The identifier defined by this declaration. */ + @Override + public Identifier getIdentifier() { + return this.var.identifier; + } +} diff --git a/src/main/java/chocopy/common/astnodes/WhileStmt.java b/src/main/java/chocopy/common/astnodes/WhileStmt.java new file mode 100644 index 0000000..9a521e1 --- /dev/null +++ b/src/main/java/chocopy/common/astnodes/WhileStmt.java @@ -0,0 +1,25 @@ +package chocopy.common.astnodes; + +import chocopy.common.analysis.NodeAnalyzer; +import java_cup.runtime.ComplexSymbolFactory.Location; + +import java.util.List; + +/** Indefinite repetition construct. */ +public class WhileStmt extends Stmt { + /** Test for whether to continue. */ + public final Expr condition; + /** Loop body. */ + public final List body; + + /** The AST for while CONDITION: BODY spanning source locations [LEFT..RIGHT]. */ + public WhileStmt(Location left, Location right, Expr condition, List body) { + super(left, right); + this.condition = condition; + this.body = body; + } + + public T dispatch(NodeAnalyzer analyzer) { + return analyzer.analyze(this); + } +} diff --git a/src/main/java/chocopy/pa2/DeclarationAnalyzer.java b/src/main/java/chocopy/pa2/DeclarationAnalyzer.java new file mode 100644 index 0000000..29aaf5a --- /dev/null +++ b/src/main/java/chocopy/pa2/DeclarationAnalyzer.java @@ -0,0 +1,55 @@ +package chocopy.pa2; + +import chocopy.common.analysis.AbstractNodeAnalyzer; +import chocopy.common.analysis.SymbolTable; +import chocopy.common.analysis.types.Type; +import chocopy.common.analysis.types.ValueType; +import chocopy.common.astnodes.*; + +/** Analyzes declarations to create a top-level symbol table. */ +public class DeclarationAnalyzer extends AbstractNodeAnalyzer { + + /** Current symbol table. Changes with new declarative region. */ + private final SymbolTable sym = new SymbolTable<>(); + /** Global symbol table. */ + private final SymbolTable globals = sym; + /** Receiver for semantic error messages. */ + private final Errors errors; + + /** A new declaration analyzer sending errors to ERRORS0. */ + public DeclarationAnalyzer(Errors errors0) { + errors = errors0; + } + + public SymbolTable getGlobals() { + return globals; + } + + @Override + public Type analyze(Program program) { + for (Declaration decl : program.declarations) { + Identifier id = decl.getIdentifier(); + String name = id.name; + + Type type = decl.dispatch(this); + + if (type == null) { + continue; + } + + if (sym.declares(name)) { + errors.semError( + id, "Duplicate declaration of identifier in same " + "scope: %s", name); + } else { + sym.put(name, type); + } + } + + return null; + } + + @Override + public Type analyze(VarDef varDef) { + return ValueType.annotationToValueType(varDef.var.type); + } +} diff --git a/src/main/java/chocopy/pa2/StudentAnalysis.java b/src/main/java/chocopy/pa2/StudentAnalysis.java new file mode 100644 index 0000000..b008a2b --- /dev/null +++ b/src/main/java/chocopy/pa2/StudentAnalysis.java @@ -0,0 +1,30 @@ +package chocopy.pa2; + +import chocopy.common.analysis.SymbolTable; +import chocopy.common.analysis.types.Type; +import chocopy.common.astnodes.Program; + +/** Top-level class for performing semantic analysis. */ +public class StudentAnalysis { + + /** + * Perform semantic analysis on PROGRAM, adding error messages and type annotations. Provide + * debugging output iff DEBUG. Returns modified tree. + */ + public static Program process(Program program, boolean debug) { + if (program.hasErrors()) { + return program; + } + + DeclarationAnalyzer declarationAnalyzer = new DeclarationAnalyzer(program.errors); + program.dispatch(declarationAnalyzer); + SymbolTable globalSym = declarationAnalyzer.getGlobals(); + + if (!program.hasErrors()) { + TypeChecker typeChecker = new TypeChecker(globalSym, program.errors); + program.dispatch(typeChecker); + } + + return program; + } +} diff --git a/src/main/java/chocopy/pa2/TypeChecker.java b/src/main/java/chocopy/pa2/TypeChecker.java new file mode 100644 index 0000000..ab8acc1 --- /dev/null +++ b/src/main/java/chocopy/pa2/TypeChecker.java @@ -0,0 +1,94 @@ +package chocopy.pa2; + +import chocopy.common.analysis.AbstractNodeAnalyzer; +import chocopy.common.analysis.SymbolTable; +import chocopy.common.analysis.types.Type; +import chocopy.common.analysis.types.ValueType; +import chocopy.common.astnodes.*; + +import static chocopy.common.analysis.types.Type.INT_TYPE; +import static chocopy.common.analysis.types.Type.OBJECT_TYPE; + +/** + * Analyzer that performs ChocoPy type checks on all nodes. Applied after collecting declarations. + */ +public class TypeChecker extends AbstractNodeAnalyzer { + + /** The current symbol table (changes depending on the function being analyzed). */ + private final SymbolTable sym; + /** Collector for errors. */ + private final Errors errors; + + /** + * Creates a type checker using GLOBALSYMBOLS for the initial global symbol table and ERRORS0 to + * receive semantic errors. + */ + public TypeChecker(SymbolTable globalSymbols, Errors errors0) { + sym = globalSymbols; + errors = errors0; + } + + /** + * Inserts an error message in NODE if there isn't one already. The message is constructed with + * MESSAGE and ARGS as for String.format. + */ + private void err(Node node, String message, Object... args) { + errors.semError(node, message, args); + } + + @Override + public Type analyze(Program program) { + for (Declaration decl : program.declarations) { + decl.dispatch(this); + } + for (Stmt stmt : program.statements) { + stmt.dispatch(this); + } + return null; + } + + @Override + public Type analyze(ExprStmt s) { + s.expr.dispatch(this); + return null; + } + + @Override + public Type analyze(IntegerLiteral i) { + return i.setInferredType(Type.INT_TYPE); + } + + @Override + public Type analyze(BinaryExpr e) { + Type t1 = e.left.dispatch(this); + Type t2 = e.right.dispatch(this); + + switch (e.operator) { + case "-": + case "*": + case "//": + case "%": + if (INT_TYPE.equals(t1) && INT_TYPE.equals(t2)) { + return e.setInferredType(INT_TYPE); + } else { + err(e, "Cannot apply operator `%s` on types `%s` and `%s`", e.operator, t1, t2); + return e.setInferredType(INT_TYPE); + } + default: + return e.setInferredType(OBJECT_TYPE); + } + } + + @Override + public Type analyze(Identifier id) { + String varName = id.name; + Type varType = sym.get(varName); + + if (varType != null && varType.isValueType()) { + return id.setInferredType(varType); + } + + err(id, "Not a variable: %s", varName); + return id.setInferredType(ValueType.OBJECT_TYPE); + } +} diff --git a/src/test/data/pa2/sample/ast_coverage.py b/src/test/data/pa2/sample/ast_coverage.py new file mode 100644 index 0000000..a27e796 --- /dev/null +++ b/src/test/data/pa2/sample/ast_coverage.py @@ -0,0 +1,38 @@ +count:int = 0 + +def foo(s: str) -> int: + return len(s) + +class bar(object): + p: bool = True + + def baz(self:"bar", xx: [int]) -> str: + global count + x:int = 0 + y:int = 1 + + def qux(y: int) -> object: + nonlocal x + if x > y: + x = -1 + + for x in xx: + self.p = x == 2 + + qux(0) # Yay! ChocoPy + + count = count + 1 + + while x <= 0: + if self.p: + xx[0] = xx[1] + self.p = not self.p + x = x + 1 + elif foo("Long"[0]) == 1: + self.p = self is None + + return "Nope" + +print(bar().baz([1,2])) + + diff --git a/src/test/data/pa2/sample/ast_coverage.py.ast b/src/test/data/pa2/sample/ast_coverage.py.ast new file mode 100644 index 0000000..18d47cd --- /dev/null +++ b/src/test/data/pa2/sample/ast_coverage.py.ast @@ -0,0 +1,627 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 36, 24 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 5 ], + "name" : "count" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 7, 1, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 13 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 12, 3, 14 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 20, 3, 22 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 17 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 4, 12, 4, 17 ], + "function" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 14 ], + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 16 ], + "name" : "s" + } ] + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 6, 1, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 7, 6, 9 ], + "name" : "bar" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 6, 11, 6, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "p" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 8, 7, 11 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 15, 7, 18 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 34, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 22 ], + "className" : "bar" + } + }, { + "kind" : "TypedVar", + "location" : [ 9, 25, 9, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 25, 9, 26 ], + "name" : "xx" + }, + "type" : { + "kind" : "ListType", + "location" : [ 9, 29, 9, 33 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 9, 30, 9, 32 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 39, 9, 41 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 10, 9, 10, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 10, 16, 10, 20 ], + "name" : "count" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 9, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 9, 11, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 11, 11, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 17, 11, 17 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 12, 9, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 9, 12, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 9 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 11, 12, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 17, 12, 17 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 9, 19, 8 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 13, 14, 15 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 17, 14, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 17 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 20, 14, 22 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 28, 14, 33 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 15, 13, 15, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 22, 15, 22 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 16, 13, 19, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 16, 16, 16, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "Identifier", + "location" : [ 16, 20, 16, 20 ], + "name" : "y" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 17, 17, 17, 22 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 17, 17, 17 ], + "name" : "x" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 17, 21, 17, 22 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 22, 17, 22 ], + "value" : 1 + } + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 19, 9, 22, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 13, 19, 13 ], + "name" : "x" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 19, 18, 19, 19 ], + "name" : "xx" + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 20, 13, 20, 27 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 13, 20, 18 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 13, 20, 16 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 18, 20, 18 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 20, 22, 20, 27 ], + "left" : { + "kind" : "Identifier", + "location" : [ 20, 22, 20, 22 ], + "name" : "x" + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 27, 20, 27 ], + "value" : 2 + } + } + } ] + }, { + "kind" : "ExprStmt", + "location" : [ 22, 9, 22, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 9, 22, 14 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 9, 22, 11 ], + "name" : "qux" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 13, 22, 13 ], + "value" : 0 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 24, 9, 24, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 24, 9, 24, 13 ], + "name" : "count" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 24, 17, 24, 25 ], + "left" : { + "kind" : "Identifier", + "location" : [ 24, 17, 24, 21 ], + "name" : "count" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 25, 24, 25 ], + "value" : 1 + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 26, 9, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 26, 15, 26, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 26, 15, 26, 15 ], + "name" : "x" + }, + "operator" : "<=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 26, 20, 26, 20 ], + "value" : 0 + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 27, 13, 34, 8 ], + "condition" : { + "kind" : "MemberExpr", + "location" : [ 27, 16, 27, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 27, 16, 27, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 21, 27, 21 ], + "name" : "p" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 28, 17, 28, 29 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 28, 17, 28, 21 ], + "list" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 18 ], + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 20, 28, 20 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 28, 25, 28, 29 ], + "list" : { + "kind" : "Identifier", + "location" : [ 28, 25, 28, 26 ], + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 28, 28, 28 ], + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 29, 17, 29, 35 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 29, 17, 29, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 29, 17, 29, 20 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 22, 29, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 29, 26, 29, 35 ], + "operator" : "not", + "operand" : { + "kind" : "MemberExpr", + "location" : [ 29, 30, 29, 35 ], + "object" : { + "kind" : "Identifier", + "location" : [ 29, 30, 29, 33 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 35, 29, 35 ], + "name" : "p" + } + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 30, 17, 30, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 30, 17, 30, 17 ], + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 30, 21, 30, 25 ], + "left" : { + "kind" : "Identifier", + "location" : [ 30, 21, 30, 21 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 25, 30, 25 ], + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 31, 13, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 31, 18, 31, 36 ], + "left" : { + "kind" : "CallExpr", + "location" : [ 31, 18, 31, 31 ], + "function" : { + "kind" : "Identifier", + "location" : [ 31, 18, 31, 20 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IndexExpr", + "location" : [ 31, 22, 31, 30 ], + "list" : { + "kind" : "StringLiteral", + "location" : [ 31, 22, 31, 27 ], + "value" : "Long" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 29, 31, 29 ], + "value" : 0 + } + } ] + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 36, 31, 36 ], + "value" : 1 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 32, 17, 32, 37 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 32, 17, 32, 22 ], + "object" : { + "kind" : "Identifier", + "location" : [ 32, 17, 32, 20 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 22, 32, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 32, 26, 32, 37 ], + "left" : { + "kind" : "Identifier", + "location" : [ 32, 26, 32, 29 ], + "name" : "self" + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 32, 34, 32, 37 ] + } + } + } ], + "elseBody" : [ ] + } ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 34, 9, 34, 21 ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 34, 16, 34, 21 ], + "value" : "Nope" + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 36, 1, 36, 23 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 36, 1, 36, 23 ], + "function" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 36, 7, 36, 22 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 36, 7, 36, 15 ], + "object" : { + "kind" : "CallExpr", + "location" : [ 36, 7, 36, 11 ], + "function" : { + "kind" : "Identifier", + "location" : [ 36, 7, 36, 9 ], + "name" : "bar" + }, + "args" : [ ] + }, + "member" : { + "kind" : "Identifier", + "location" : [ 36, 13, 36, 15 ], + "name" : "baz" + } + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 36, 17, 36, 21 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 36, 18, 36, 18 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 36, 20, 36, 20 ], + "value" : 2 + } ] + } ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/ast_coverage.py.ast.typed b/src/test/data/pa2/sample/ast_coverage.py.ast.typed new file mode 100644 index 0000000..709f895 --- /dev/null +++ b/src/test/data/pa2/sample/ast_coverage.py.ast.typed @@ -0,0 +1,952 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 36, 24 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 5 ], + "name" : "count" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 7, 1, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 12, 3, 14 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 20, 3, 22 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 17 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 4, 12, 4, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "len" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + } ] + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 6, 1, 36, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 6, 7, 6, 9 ], + "name" : "bar" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 6, 11, 6, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 18 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "p" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 8, 7, 11 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 15, 7, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 34, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 22 ], + "className" : "bar" + } + }, { + "kind" : "TypedVar", + "location" : [ 9, 25, 9, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 25, 9, 26 ], + "name" : "xx" + }, + "type" : { + "kind" : "ListType", + "location" : [ 9, 29, 9, 33 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 9, 30, 9, 32 ], + "className" : "int" + } + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 39, 9, 41 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 10, 9, 10, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 10, 16, 10, 20 ], + "name" : "count" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 9, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 9, 11, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 11, 11, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 17, 11, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 12, 9, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 9, 12, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 9 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 11, 12, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 17, 12, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 9, 19, 8 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 13, 14, 15 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 17, 14, 22 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 17, 14, 17 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 20, 14, 22 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 28, 14, 33 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 15, 13, 15, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 22, 15, 22 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 16, 13, 19, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 16, 16, 16, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : ">", + "right" : { + "kind" : "Identifier", + "location" : [ 16, 20, 16, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 17, 17, 17, 22 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 17, 17, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 17, 21, 17, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 17, 22, 17, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 19, 9, 22, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 13, 19, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 19, 18, 19, 19 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "xx" + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 20, 13, 20, 27 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 13, 20, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 13, 20, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 18, 20, 18 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 20, 22, 20, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 20, 22, 20, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 20, 27, 20, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + } ] + }, { + "kind" : "ExprStmt", + "location" : [ 22, 9, 22, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 9, 22, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 9, 22, 11 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "qux" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 13, 22, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 24, 9, 24, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 24, 9, 24, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "count" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 24, 17, 24, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 24, 17, 24, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "count" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 25, 24, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "WhileStmt", + "location" : [ 26, 9, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 26, 15, 26, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 26, 15, 26, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "<=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 26, 20, 26, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, + "body" : [ { + "kind" : "IfStmt", + "location" : [ 27, 13, 34, 8 ], + "condition" : { + "kind" : "MemberExpr", + "location" : [ 27, 16, 27, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 27, 16, 27, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 21, 27, 21 ], + "name" : "p" + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 28, 17, 28, 29 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 28, 17, 28, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 28, 17, 28, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 20, 28, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 28, 25, 28, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 28, 25, 28, 26 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "xx" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 28, 28, 28, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 29, 17, 29, 35 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 29, 17, 29, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 29, 17, 29, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 22, 29, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "UnaryExpr", + "location" : [ 29, 26, 29, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "MemberExpr", + "location" : [ 29, 30, 29, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 29, 30, 29, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 35, 29, 35 ], + "name" : "p" + } + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 30, 17, 30, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 30, 17, 30, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 30, 21, 30, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 30, 21, 30, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 25, 30, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 31, 13, 34, 8 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 31, 18, 31, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "CallExpr", + "location" : [ 31, 18, 31, 31 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 31, 18, 31, 20 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "IndexExpr", + "location" : [ 31, 22, 31, 30 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "StringLiteral", + "location" : [ 31, 22, 31, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Long" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 29, 31, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ] + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 31, 36, 31, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, + "thenBody" : [ { + "kind" : "AssignStmt", + "location" : [ 32, 17, 32, 37 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 32, 17, 32, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 32, 17, 32, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 32, 22, 32, 22 ], + "name" : "p" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 32, 26, 32, 37 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 32, 26, 32, 29 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "name" : "self" + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 32, 34, 32, 37 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + } ], + "elseBody" : [ ] + } ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 34, 9, 34, 21 ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 34, 16, 34, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Nope" + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 36, 1, 36, 23 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 36, 1, 36, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "MethodCallExpr", + "location" : [ 36, 7, 36, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 36, 7, 36, 15 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "bar" + }, { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "object" : { + "kind" : "CallExpr", + "location" : [ 36, 7, 36, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bar" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 36, 7, 36, 9 ], + "name" : "bar" + }, + "args" : [ ] + }, + "member" : { + "kind" : "Identifier", + "location" : [ 36, 13, 36, 15 ], + "name" : "baz" + } + }, + "args" : [ { + "kind" : "ListExpr", + "location" : [ 36, 17, 36, 21 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 36, 18, 36, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 36, 20, 36, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + } ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_assign_expr.py b/src/test/data/pa2/sample/bad_assign_expr.py new file mode 100644 index 0000000..9e68917 --- /dev/null +++ b/src/test/data/pa2/sample/bad_assign_expr.py @@ -0,0 +1,11 @@ +x:int = 0 +y:int = 0 +z:bool = False + +x = z = 1 # Only one error here (assignment to `x = 1` should succeed) +x = y = None +x = y = [] +x = a = None +x = a = [] +x = y = True + diff --git a/src/test/data/pa2/sample/bad_assign_expr.py.ast b/src/test/data/pa2/sample/bad_assign_expr.py.ast new file mode 100644 index 0000000..6651bd2 --- /dev/null +++ b/src/test/data/pa2/sample/bad_assign_expr.py.ast @@ -0,0 +1,177 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 10, 3, 14 ], + "value" : false + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 9, 6, 12 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 9, 7, 10 ], + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "a" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "a" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 9, 9, 10 ], + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 12 ], + "value" : true + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_assign_expr.py.ast.typed b/src/test/data/pa2/sample/bad_assign_expr.py.ast.typed new file mode 100644 index 0000000..2f99fae --- /dev/null +++ b/src/test/data/pa2/sample/bad_assign_expr.py.ast.typed @@ -0,0 +1,301 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 10, 3, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "errorMsg" : "Expected type `bool`; got type `int`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 12 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 9, 6, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 10 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 9, 7, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "errorMsg" : "Not a variable: a", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "a" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 10 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "errorMsg" : "Not a variable: a", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "a" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 9, 9, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 12 ], + "errorMsg" : "Expected type `int`; got type `bool`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 10, 5, 10, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 9 ], + "message" : "Expected type `bool`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 12 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 7, 1, 7, 10 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 12 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 5 ], + "message" : "Not a variable: a" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 10 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 9, 5, 9, 5 ], + "message" : "Not a variable: a" + }, { + "kind" : "CompilerError", + "location" : [ 10, 1, 10, 12 ], + "message" : "Expected type `int`; got type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_attr.py b/src/test/data/pa2/sample/bad_class_attr.py new file mode 100644 index 0000000..b30eb7c --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_attr.py @@ -0,0 +1,13 @@ +class A(object): + x:int = 1 + + def foo(self:"A") -> int: + return 0 + +class B(A): + x:int = 2 # Bad + foo:str = "" # Bad + +A() + + diff --git a/src/test/data/pa2/sample/bad_class_attr.py.ast b/src/test/data/pa2/sample/bad_class_attr.py.ast new file mode 100644 index 0000000..ec25404 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_attr.py.ast @@ -0,0 +1,155 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 11, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 9, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 7 ], + "name" : "foo" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 9, 9, 11 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 9, 15, 9, 16 ], + "value" : "" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_attr.py.ast.typed b/src/test/data/pa2/sample/bad_class_attr.py.ast.typed new file mode 100644 index 0000000..5ea1e74 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_attr.py.ast.typed @@ -0,0 +1,165 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 11, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 9, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "errorMsg" : "Cannot re-define attribute: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 7 ], + "errorMsg" : "Cannot re-define attribute: foo", + "name" : "foo" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 9, 9, 11 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 9, 15, 9, 16 ], + "value" : "" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 5 ], + "message" : "Cannot re-define attribute: x" + }, { + "kind" : "CompilerError", + "location" : [ 9, 5, 9, 7 ], + "message" : "Cannot re-define attribute: foo" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_attr_type.py b/src/test/data/pa2/sample/bad_class_attr_type.py new file mode 100644 index 0000000..5a7bee7 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_attr_type.py @@ -0,0 +1,4 @@ +class A(object): + x:int = True + +A() diff --git a/src/test/data/pa2/sample/bad_class_attr_type.py.ast b/src/test/data/pa2/sample/bad_class_attr_type.py.ast new file mode 100644 index 0000000..6b9d252 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_attr_type.py.ast @@ -0,0 +1,60 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 13, 2, 16 ], + "value" : true + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 4, 1, 4, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_attr_type.py.ast.typed b/src/test/data/pa2/sample/bad_class_attr_type.py.ast.typed new file mode 100644 index 0000000..f0a9461 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_attr_type.py.ast.typed @@ -0,0 +1,73 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 16 ], + "errorMsg" : "Expected type `int`; got type `bool`", + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 13, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 4, 1, 4, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 5, 2, 16 ], + "message" : "Expected type `int`; got type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_init_override.py b/src/test/data/pa2/sample/bad_class_init_override.py new file mode 100644 index 0000000..ceb612c --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_init_override.py @@ -0,0 +1,8 @@ +class A(object): + x:int = 1 + + def __init__(self:"A", x:int): # Bad override + pass + +A(1) + diff --git a/src/test/data/pa2/sample/bad_class_init_override.py.ast b/src/test/data/pa2/sample/bad_class_init_override.py.ast new file mode 100644 index 0000000..bdd151d --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_init_override.py.ast @@ -0,0 +1,106 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 18, 4, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 25 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 28, 4, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 28, 4, 28 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 30, 4, 32 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 34, 4, 34 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 4 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 4 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "A" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_init_override.py.ast.typed b/src/test/data/pa2/sample/bad_class_init_override.py.ast.typed new file mode 100644 index 0000000..9daa89c --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_init_override.py.ast.typed @@ -0,0 +1,111 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 16 ], + "errorMsg" : "Method overridden with different type signature: __init__", + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 18, 4, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 25 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 28, 4, 32 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 28, 4, 28 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 30, 4, 32 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 34, 4, 34 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 4 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 4 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "A" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 9, 4, 16 ], + "message" : "Method overridden with different type signature: __init__" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_init_return.py b/src/test/data/pa2/sample/bad_class_init_return.py new file mode 100644 index 0000000..cc6eb34 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_init_return.py @@ -0,0 +1,5 @@ +class A(object): + def __init__(self:"A"): + return 1 # Bad + +A() diff --git a/src/test/data/pa2/sample/bad_class_init_return.py.ast b/src/test/data/pa2/sample/bad_class_init_return.py.ast new file mode 100644 index 0000000..24e972f --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_init_return.py.ast @@ -0,0 +1,75 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 5, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 18, 2, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 18, 2, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 23, 2, 25 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 27, 2, 27 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "value" : 1 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 5, 1, 5, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_init_return.py.ast.typed b/src/test/data/pa2/sample/bad_class_init_return.py.ast.typed new file mode 100644 index 0000000..cf0cde2 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_init_return.py.ast.typed @@ -0,0 +1,88 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 5, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 23 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 18, 2, 25 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 18, 2, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 23, 2, 25 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 27, 2, 27 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "errorMsg" : "Expected type ``; got type `int`", + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 5, 1, 5, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 3, 9, 3, 16 ], + "message" : "Expected type ``; got type `int`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_member_expr.py b/src/test/data/pa2/sample/bad_class_member_expr.py new file mode 100644 index 0000000..bbfa1c1 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_member_expr.py @@ -0,0 +1,6 @@ +x:int = 0 +o:object = None + +x.foo +o.bar +o.baz = 1 diff --git a/src/test/data/pa2/sample/bad_class_member_expr.py.ast b/src/test/data/pa2/sample/bad_class_member_expr.py.ast new file mode 100644 index 0000000..4949375 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_member_expr.py.ast @@ -0,0 +1,110 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ] + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 4, 1, 4, 5 ], + "object" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 4, 3, 4, 5 ], + "name" : "foo" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 5, 1, 5, 5 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 3, 5, 5 ], + "name" : "bar" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 6, 1, 6, 5 ], + "object" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 6, 3, 6, 5 ], + "name" : "baz" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 1 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_member_expr.py.ast.typed b/src/test/data/pa2/sample/bad_class_member_expr.py.ast.typed new file mode 100644 index 0000000..4e570c0 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_member_expr.py.ast.typed @@ -0,0 +1,161 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 4, 1, 4, 5 ], + "errorMsg" : "There is no attribute named `foo` in class `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 4, 3, 4, 5 ], + "name" : "foo" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "MemberExpr", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "There is no attribute named `bar` in class `object`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 3, 5, 5 ], + "name" : "bar" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 6, 1, 6, 5 ], + "errorMsg" : "There is no attribute named `baz` in class `object`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 6, 3, 6, 5 ], + "name" : "baz" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 5 ], + "message" : "There is no attribute named `foo` in class `int`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "There is no attribute named `bar` in class `object`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 5 ], + "message" : "There is no attribute named `baz` in class `object`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method.py b/src/test/data/pa2/sample/bad_class_method.py new file mode 100644 index 0000000..d5a10d8 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method.py @@ -0,0 +1,14 @@ +class A(object): + x:int = 1 + + def foo(self:"A") -> int: # OK + return 0 + + def bar() -> int: # Needs self param + return 0 + + def baz(self:int) -> int: # Incorrect self type + return 0 + +A() + diff --git a/src/test/data/pa2/sample/bad_class_method.py.ast b/src/test/data/pa2/sample/bad_class_method.py.ast new file mode 100644 index 0000000..7c359ef --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method.py.ast @@ -0,0 +1,158 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 13, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 5, 8, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 11 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 9, 8, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 16, 8, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 13, 10, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 13, 10, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 18, 10, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 26, 10, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 13, 1, 13, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method.py.ast.typed b/src/test/data/pa2/sample/bad_class_method.py.ast.typed new file mode 100644 index 0000000..9e08da8 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method.py.ast.typed @@ -0,0 +1,168 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 13, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 18, 4, 20 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 26, 4, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 5, 8, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 11 ], + "errorMsg" : "First parameter of the following method must be of the enclosing class: bar", + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 9, 8, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 16, 8, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 10, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 11 ], + "errorMsg" : "First parameter of the following method must be of the enclosing class: baz", + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 10, 13, 10, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 10, 13, 10, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 10, 18, 10, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 10, 26, 10, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 13, 1, 13, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 9, 7, 11 ], + "message" : "First parameter of the following method must be of the enclosing class: bar" + }, { + "kind" : "CompilerError", + "location" : [ 10, 9, 10, 11 ], + "message" : "First parameter of the following method must be of the enclosing class: baz" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method_invoke.py b/src/test/data/pa2/sample/bad_class_method_invoke.py new file mode 100644 index 0000000..d5bb97c --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_invoke.py @@ -0,0 +1,30 @@ +class A(object): + x:int = 1 + + def get_A(self: "A") -> int: + return self.x + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + + def set_A(self: "C", val: int) -> object: + self.x = val + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() + +a.get_A(1) +b.get_Z() +c.set_A() +c.set_A(False) +c.set_A(None) + diff --git a/src/test/data/pa2/sample/bad_class_method_invoke.py.ast b/src/test/data/pa2/sample/bad_class_method_invoke.py.ast new file mode 100644 index 0000000..e01db23 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_invoke.py.ast @@ -0,0 +1,474 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 29, 14 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 25, 1, 25, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 1, 25, 10 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 7 ], + "name" : "get_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 25, 9, 25, 9 ], + "value" : 1 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 26, 1, 26, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 1, 26, 9 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 7 ], + "name" : "get_Z" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 9 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 28, 1, 28, 14 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 28, 1, 28, 14 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 28, 1, 28, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 28, 3, 28, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "BooleanLiteral", + "location" : [ 28, 9, 28, 13 ], + "value" : false + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 29, 1, 29, 13 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 29, 1, 29, 13 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 29, 1, 29, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 29, 1, 29, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 3, 29, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "NoneLiteral", + "location" : [ 29, 9, 29, 12 ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method_invoke.py.ast.typed b/src/test/data/pa2/sample/bad_class_method_invoke.py.ast.typed new file mode 100644 index 0000000..77867db --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_invoke.py.ast.typed @@ -0,0 +1,668 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 29, 14 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 25, 1, 25, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 1, 25, 10 ], + "errorMsg" : "Expected 0 arguments; got 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 7 ], + "name" : "get_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 25, 9, 25, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 26, 1, 26, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 1, 26, 9 ], + "errorMsg" : "There is no method named `get_Z` in class `B`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 7 ], + "name" : "get_Z" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 9 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 9 ], + "errorMsg" : "Expected 1 arguments; got 0", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 28, 1, 28, 14 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 28, 1, 28, 14 ], + "errorMsg" : "Expected type `int`; got type `bool` in parameter 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 28, 1, 28, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 28, 3, 28, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "BooleanLiteral", + "location" : [ 28, 9, 28, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 29, 1, 29, 13 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 29, 1, 29, 13 ], + "errorMsg" : "Expected type `int`; got type `` in parameter 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 29, 1, 29, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 29, 1, 29, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 29, 3, 29, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "NoneLiteral", + "location" : [ 29, 9, 29, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 25, 1, 25, 10 ], + "message" : "Expected 0 arguments; got 1" + }, { + "kind" : "CompilerError", + "location" : [ 26, 1, 26, 9 ], + "message" : "There is no method named `get_Z` in class `B`" + }, { + "kind" : "CompilerError", + "location" : [ 27, 1, 27, 9 ], + "message" : "Expected 1 arguments; got 0" + }, { + "kind" : "CompilerError", + "location" : [ 28, 1, 28, 14 ], + "message" : "Expected type `int`; got type `bool` in parameter 1" + }, { + "kind" : "CompilerError", + "location" : [ 29, 1, 29, 13 ], + "message" : "Expected type `int`; got type `` in parameter 1" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method_override.py b/src/test/data/pa2/sample/bad_class_method_override.py new file mode 100644 index 0000000..3f76544 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_override.py @@ -0,0 +1,33 @@ +class A(object): + def foo(self:"A", x:int) -> int: + return x + + def bar(self:"A", x:int) -> int: + return x + + def baz(self:"A", x:int) -> int: + return x + + def qux(self:"A", x:int) -> int: + return x + +class B(A): + + # OK override + def foo(self:"B", x:int) -> int: + return 0 + + # Bad override + def bar(self:"B") -> int: + return 0 + + # Bad override + def baz(self:"B", x:int) -> bool: + return True + + # Bad override + def qux(self:"B", x:bool) -> int: + return 0 + +B() + diff --git a/src/test/data/pa2/sample/bad_class_method_override.py.ast b/src/test/data/pa2/sample/bad_class_method_override.py.ast new file mode 100644 index 0000000..e82a758 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_override.py.ast @@ -0,0 +1,439 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 32, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 14, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 13, 2, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 13, 2, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 18, 2, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 2, 23, 2, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 23, 2, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 25, 2, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 33, 2, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 3, 16, 3, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 13, 5, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 13, 5, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 18, 5, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 23, 5, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 23, 5, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 25, 5, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 33, 5, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 9, 6, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 6, 16, 6, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 13, 8, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 18, 8, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 8, 23, 8, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 23, 8, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 25, 8, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 33, 8, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 9, 9, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 11 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 13, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 13, 11, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 18, 11, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 11, 23, 11, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 23, 11, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 25, 11, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 33, 11, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 12, 16, 12, 16 ], + "name" : "x" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 14, 1, 32, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 7, 14, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 17, 5, 18, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 13, 17, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 18, 17, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 17, 23, 17, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 23, 17, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 25, 17, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 33, 17, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 18, 9, 18, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 16, 18, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 21, 5, 22, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 21, 13, 21, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 21, 13, 21, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 21, 18, 21, 20 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 21, 26, 21, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 22, 9, 22, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 16, 22, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 25, 5, 26, 20 ], + "name" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 25, 13, 25, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 13, 25, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 18, 25, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 25, 23, 25, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 23, 25, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 25, 25, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 25, 33, 25, 36 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 26, 9, 26, 19 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 26, 16, 26, 19 ], + "value" : true + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 29, 5, 30, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 29, 9, 29, 11 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 29, 13, 29, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 18, 29, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 29, 23, 29, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 23, 29, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 25, 29, 28 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 29, 34, 29, 36 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 30, 9, 30, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 16, 30, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 32, 1, 32, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 32, 1, 32, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 1 ], + "name" : "B" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method_override.py.ast.typed b/src/test/data/pa2/sample/bad_class_method_override.py.ast.typed new file mode 100644 index 0000000..68716c5 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_override.py.ast.typed @@ -0,0 +1,454 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 32, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 14, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 3, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 2, 13, 2, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 13, 2, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 18, 2, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 2, 23, 2, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 23, 2, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 25, 2, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 33, 2, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 3, 16, 3, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 11 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 13, 5, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 13, 5, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 18, 5, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 5, 23, 5, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 23, 5, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 25, 5, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 33, 5, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 9, 6, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 6, 16, 6, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 11 ], + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 13, 8, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 18, 8, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 8, 23, 8, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 23, 8, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 25, 8, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 33, 8, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 9, 9, 9, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 11 ], + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 13, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 13, 11, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 18, 11, 20 ], + "className" : "A" + } + }, { + "kind" : "TypedVar", + "location" : [ 11, 23, 11, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 23, 11, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 25, 11, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 33, 11, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 12, 16, 12, 16 ], + "name" : "x" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 14, 1, 32, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 7, 14, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 17, 5, 18, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 13, 17, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 18, 17, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 17, 23, 17, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 23, 17, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 25, 17, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 33, 17, 35 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 18, 9, 18, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 16, 18, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 21, 5, 22, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 11 ], + "errorMsg" : "Method overridden with different type signature: bar", + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 21, 13, 21, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 21, 13, 21, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 21, 18, 21, 20 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 21, 26, 21, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 22, 9, 22, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 16, 22, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 25, 5, 26, 20 ], + "name" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 11 ], + "errorMsg" : "Method overridden with different type signature: baz", + "name" : "baz" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 25, 13, 25, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 13, 25, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 18, 25, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 25, 23, 25, 27 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 25, 23, 25, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 25, 25, 25, 27 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 25, 33, 25, 36 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 26, 9, 26, 19 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 26, 16, 26, 19 ], + "value" : true + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 29, 5, 30, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 29, 9, 29, 11 ], + "errorMsg" : "Method overridden with different type signature: qux", + "name" : "qux" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 29, 13, 29, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 13, 29, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 18, 29, 20 ], + "className" : "B" + } + }, { + "kind" : "TypedVar", + "location" : [ 29, 23, 29, 28 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 23, 29, 23 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 25, 29, 28 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 29, 34, 29, 36 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 30, 9, 30, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 30, 16, 30, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 32, 1, 32, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 32, 1, 32, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 1 ], + "name" : "B" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 21, 9, 21, 11 ], + "message" : "Method overridden with different type signature: bar" + }, { + "kind" : "CompilerError", + "location" : [ 25, 9, 25, 11 ], + "message" : "Method overridden with different type signature: baz" + }, { + "kind" : "CompilerError", + "location" : [ 29, 9, 29, 11 ], + "message" : "Method overridden with different type signature: qux" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method_override_attr.py b/src/test/data/pa2/sample/bad_class_method_override_attr.py new file mode 100644 index 0000000..52c01bd --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_override_attr.py @@ -0,0 +1,8 @@ +class A(object): + f:int = 3 + +class B(A): + def f(self:B) -> int: + return 3 + +A() diff --git a/src/test/data/pa2/sample/bad_class_method_override_attr.py.ast b/src/test/data/pa2/sample/bad_class_method_override_attr.py.ast new file mode 100644 index 0000000..1574d53 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_override_attr.py.ast @@ -0,0 +1,111 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 2, 2, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 2, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 2, 2, 2 ], + "name" : "f" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 10, 2, 10 ], + "value" : 3 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 2, 6, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 6, 5, 6 ], + "name" : "f" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 8, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 8, 5, 11 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 13, 5, 13 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 3, 6, 10 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 10, 6, 10 ], + "value" : 3 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_method_override_attr.py.ast.typed b/src/test/data/pa2/sample/bad_class_method_override_attr.py.ast.typed new file mode 100644 index 0000000..fcfb779 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_method_override_attr.py.ast.typed @@ -0,0 +1,116 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 2, 2, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 2, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 2, 2, 2 ], + "name" : "f" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 10, 2, 10 ], + "value" : 3 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 2, 6, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 6, 5, 6 ], + "errorMsg" : "Cannot re-define attribute: f", + "name" : "f" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 8, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 8, 5, 11 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 13, 5, 13 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 6, 3, 6, 10 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 10, 6, 10 ], + "value" : 3 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 6, 5, 6 ], + "message" : "Cannot re-define attribute: f" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_super.py b/src/test/data/pa2/sample/bad_class_super.py new file mode 100644 index 0000000..9701776 --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_super.py @@ -0,0 +1,15 @@ +# Super is not defined +class A(B): + x:int = 1 + +z:int = 2 + +# Super is not a class +class B(z): + x:int = 1 + +# Cannot extend special classes +class C(int): + x:int = 1 + +A() diff --git a/src/test/data/pa2/sample/bad_class_super.py.ast b/src/test/data/pa2/sample/bad_class_super.py.ast new file mode 100644 index 0000000..4aed62a --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_super.py.ast @@ -0,0 +1,154 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 15, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 3, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 7, 3, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "value" : 2 + } + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "z" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 13, 9, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 12, 1, 13, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 12, 7, 12, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 11 ], + "name" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 13, 5, 13, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 5, 13, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 7, 13, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 13, 13, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 15, 1, 15, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 15, 1, 15, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_class_super.py.ast.typed b/src/test/data/pa2/sample/bad_class_super.py.ast.typed new file mode 100644 index 0000000..128383f --- /dev/null +++ b/src/test/data/pa2/sample/bad_class_super.py.ast.typed @@ -0,0 +1,169 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 15, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 3, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 9 ], + "errorMsg" : "Super-class not defined: B", + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 7, 3, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 9, 5, 9 ], + "value" : 2 + } + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "errorMsg" : "Super-class must be a class: z", + "name" : "z" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 13, 9, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 12, 1, 13, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 12, 7, 12, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 12, 9, 12, 11 ], + "errorMsg" : "Cannot extend special class: int", + "name" : "int" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 13, 5, 13, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 5, 13, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 7, 13, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 13, 13, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 15, 1, 15, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 15, 1, 15, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 9, 2, 9 ], + "message" : "Super-class not defined: B" + }, { + "kind" : "CompilerError", + "location" : [ 8, 9, 8, 9 ], + "message" : "Super-class must be a class: z" + }, { + "kind" : "CompilerError", + "location" : [ 12, 9, 12, 11 ], + "message" : "Cannot extend special class: int" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_concat.py b/src/test/data/pa2/sample/bad_concat.py new file mode 100644 index 0000000..56e7802 --- /dev/null +++ b/src/test/data/pa2/sample/bad_concat.py @@ -0,0 +1,3 @@ +"Hello" + ["World"] +1 + [2] +[] + [1] diff --git a/src/test/data/pa2/sample/bad_concat.py.ast b/src/test/data/pa2/sample/bad_concat.py.ast new file mode 100644 index 0000000..0fdfbd6 --- /dev/null +++ b/src/test/data/pa2/sample/bad_concat.py.ast @@ -0,0 +1,77 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 19 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 19 ], + "left" : { + "kind" : "StringLiteral", + "location" : [ 1, 1, 1, 7 ], + "value" : "Hello" + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 11, 1, 19 ], + "elements" : [ { + "kind" : "StringLiteral", + "location" : [ 1, 12, 1, 18 ], + "value" : "World" + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 7 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 2, 5, 2, 7 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "value" : 2 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 8 ], + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 2 ], + "elements" : [ ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 6, 3, 8 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 7, 3, 7 ], + "value" : 1 + } ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_concat.py.ast.typed b/src/test/data/pa2/sample/bad_concat.py.ast.typed new file mode 100644 index 0000000..60f5b0c --- /dev/null +++ b/src/test/data/pa2/sample/bad_concat.py.ast.typed @@ -0,0 +1,149 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 19 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 19 ], + "errorMsg" : "Cannot apply operator `+` on types `str` and `[str]`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "left" : { + "kind" : "StringLiteral", + "location" : [ 1, 1, 1, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 11, 1, 19 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "str" + } + }, + "elements" : [ { + "kind" : "StringLiteral", + "location" : [ 1, 12, 1, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 7 ], + "errorMsg" : "Cannot apply operator `+` on types `int` and `[int]`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 2, 5, 2, 7 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 8 ], + "errorMsg" : "Cannot apply operator `+` on types `` and `[int]`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 6, 3, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 7, 3, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 19 ], + "message" : "Cannot apply operator `+` on types `str` and `[str]`" + }, { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 7 ], + "message" : "Cannot apply operator `+` on types `int` and `[int]`" + }, { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 8 ], + "message" : "Cannot apply operator `+` on types `` and `[int]`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_class.py b/src/test/data/pa2/sample/bad_duplicate_class.py new file mode 100644 index 0000000..8f8dd05 --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_class.py @@ -0,0 +1,18 @@ +class A(object): + x:int = 1 + +z:bool = True + +# Duplicate +class A(object): + x:int = 1 + +# Duplicate +class str(object): + x:int = 1 + +# Duplicate +class z(object): + x:int = 1 + +A() diff --git a/src/test/data/pa2/sample/bad_duplicate_class.py.ast b/src/test/data/pa2/sample/bad_duplicate_class.py.ast new file mode 100644 index 0000000..547360b --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_class.py.ast @@ -0,0 +1,190 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 10, 4, 13 ], + "value" : true + } + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 8, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 12, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 9 ], + "name" : "str" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 13, 12, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 15, 1, 16, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 7 ], + "name" : "z" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 16, 5, 16, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 16, 5, 16, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 7, 16, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 13, 16, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_class.py.ast.typed b/src/test/data/pa2/sample/bad_duplicate_class.py.ast.typed new file mode 100644 index 0000000..3791ada --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_class.py.ast.typed @@ -0,0 +1,205 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 10, 4, 13 ], + "value" : true + } + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 8, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: A", + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 8, 5, 8, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 8, 5, 8, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 7, 8, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 13, 8, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 12, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 9 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: str", + "name" : "str" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 16 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 13, 12, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 15, 1, 16, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 7 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: z", + "name" : "z" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 16, 5, 16, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 16, 5, 16, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 7, 16, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 16, 13, 16, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 7, 7, 7 ], + "message" : "Duplicate declaration of identifier in same scope: A" + }, { + "kind" : "CompilerError", + "location" : [ 11, 7, 11, 9 ], + "message" : "Duplicate declaration of identifier in same scope: str" + }, { + "kind" : "CompilerError", + "location" : [ 15, 7, 15, 7 ], + "message" : "Duplicate declaration of identifier in same scope: z" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_class_member.py b/src/test/data/pa2/sample/bad_duplicate_class_member.py new file mode 100644 index 0000000..7a5026f --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_class_member.py @@ -0,0 +1,12 @@ +class A(object): + x:int = 1 # OK + + def foo(self: "A") -> int: # OK + return 0 + + x:int = 1 # Duplicate + + def foo(self: "A") -> int: # Duplicate + return 0 + +A() diff --git a/src/test/data/pa2/sample/bad_duplicate_class_member.py.ast b/src/test/data/pa2/sample/bad_duplicate_class_member.py.ast new file mode 100644 index 0000000..58b0ddb --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_class_member.py.ast @@ -0,0 +1,156 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 12, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 19, 4, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 27, 4, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 19, 9, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 27, 9, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 16, 10, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_class_member.py.ast.typed b/src/test/data/pa2/sample/bad_duplicate_class_member.py.ast.typed new file mode 100644 index 0000000..cb97ac4 --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_class_member.py.ast.typed @@ -0,0 +1,166 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 4 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 12, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 11 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 13, 4, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 13, 4, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 19, 4, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 27, 4, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 16, 5, 16 ], + "value" : 0 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: foo", + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 9, 13, 9, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 19, 9, 21 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 27, 9, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 16, 10, 16 ], + "value" : 0 + } + } ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 3 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 3 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "A" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 5 ], + "message" : "Duplicate declaration of identifier in same scope: x" + }, { + "kind" : "CompilerError", + "location" : [ 9, 9, 9, 11 ], + "message" : "Duplicate declaration of identifier in same scope: foo" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_global.py b/src/test/data/pa2/sample/bad_duplicate_global.py new file mode 100644 index 0000000..4b293ea --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_global.py @@ -0,0 +1,18 @@ +x:int = 1 + +def foo() -> object: + pass + +# `foo` cannot be redefined in the same scope +def foo() -> object: + pass + +# `print` cannot be redefined in the same scope +def print(val:object) -> object: + pass + +# `x` cannot be redefined in the same scope +x:int = 2 + + +foo() diff --git a/src/test/data/pa2/sample/bad_duplicate_global.py.ast b/src/test/data/pa2/sample/bad_duplicate_global.py.ast new file mode 100644 index 0000000..76e6707 --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_global.py.ast @@ -0,0 +1,129 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 14, 3, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 9 ], + "name" : "print" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 11, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 13 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 15, 11, 20 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 26, 11, 31 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 15, 1, 15, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 15, 1, 15, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 15, 3, 15, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 15, 9, 15, 9 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_global.py.ast.typed b/src/test/data/pa2/sample/bad_duplicate_global.py.ast.typed new file mode 100644 index 0000000..7d72792 --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_global.py.ast.typed @@ -0,0 +1,144 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 4, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 14, 3, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: foo", + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 11, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 9 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: print", + "name" : "print" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 11, 11, 11, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 11, 11, 13 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 15, 11, 20 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 26, 11, 31 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 15, 1, 15, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 15, 1, 15, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 15, 3, 15, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 15, 9, 15, 9 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 18, 1, 18, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 18, 1, 18, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 7 ], + "message" : "Duplicate declaration of identifier in same scope: foo" + }, { + "kind" : "CompilerError", + "location" : [ 11, 5, 11, 9 ], + "message" : "Duplicate declaration of identifier in same scope: print" + }, { + "kind" : "CompilerError", + "location" : [ 15, 1, 15, 1 ], + "message" : "Duplicate declaration of identifier in same scope: x" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_global_2.py b/src/test/data/pa2/sample/bad_duplicate_global_2.py new file mode 100644 index 0000000..62ee129 --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_global_2.py @@ -0,0 +1,6 @@ +class x(object): + pass + +x:int = 5 + +pass diff --git a/src/test/data/pa2/sample/bad_duplicate_global_2.py.ast b/src/test/data/pa2/sample/bad_duplicate_global_2.py.ast new file mode 100644 index 0000000..c3a5985 --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_global_2.py.ast @@ -0,0 +1,47 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "x" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 5 + } + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_global_2.py.ast.typed b/src/test/data/pa2/sample/bad_duplicate_global_2.py.ast.typed new file mode 100644 index 0000000..506a6ca --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_global_2.py.ast.typed @@ -0,0 +1,52 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "x" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 5 + } + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 1 ], + "message" : "Duplicate declaration of identifier in same scope: x" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_local.py b/src/test/data/pa2/sample/bad_duplicate_local.py new file mode 100644 index 0000000..bb25faf --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_local.py @@ -0,0 +1,21 @@ +x:int = 1 +y:int = 2 +z:int = 3 + +def foo(x:int) -> object: + y:int = 4 # OK + x:int = 5 # Duplicate declaration + global z # OK + global y # Duplicate declaration + + def x() -> int: # Duplicate declaration + return 0 + + pass + +def bar(x:int, x:int) -> int: # Duplicate params + return x + + +foo(1) + diff --git a/src/test/data/pa2/sample/bad_duplicate_local.py.ast b/src/test/data/pa2/sample/bad_duplicate_local.py.ast new file mode 100644 index 0000000..53f6fad --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_local.py.ast @@ -0,0 +1,257 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 20, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 14, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 5 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "z" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 12 ], + "name" : "y" + } + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 16, 11, 18 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 16, 12, 16 ], + "value" : 0 + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 16, 1, 17, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 16, 9, 16, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 9, 16, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 11, 16, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 16, 16, 16, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 18, 16, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 16, 26, 16, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 17, 5, 17, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 17, 12, 17, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 20, 1, 20, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 20, 1, 20, 6 ], + "function" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 20, 5, 20, 5 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_duplicate_local.py.ast.typed b/src/test/data/pa2/sample/bad_duplicate_local.py.ast.typed new file mode 100644 index 0000000..1559865 --- /dev/null +++ b/src/test/data/pa2/sample/bad_duplicate_local.py.ast.typed @@ -0,0 +1,277 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 20, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 14, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 7, 7, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 13, 7, 13 ], + "value" : 5 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "z" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 12 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: y", + "name" : "y" + } + }, { + "kind" : "FuncDef", + "location" : [ 11, 5, 12, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 11, 16, 11, 18 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 12, 9, 12, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 16, 12, 16 ], + "value" : 0 + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 16, 1, 17, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 16, 9, 16, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 9, 16, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 11, 16, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 16, 16, 16, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 16, 16, 16, 16 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: x", + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 16, 18, 16, 20 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 16, 26, 16, 28 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 17, 5, 17, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 17, 12, 17, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 20, 1, 20, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 20, 1, 20, 6 ], + "function" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 20, 5, 20, 5 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 5 ], + "message" : "Duplicate declaration of identifier in same scope: x" + }, { + "kind" : "CompilerError", + "location" : [ 9, 12, 9, 12 ], + "message" : "Duplicate declaration of identifier in same scope: y" + }, { + "kind" : "CompilerError", + "location" : [ 11, 9, 11, 9 ], + "message" : "Duplicate declaration of identifier in same scope: x" + }, { + "kind" : "CompilerError", + "location" : [ 16, 16, 16, 16 ], + "message" : "Duplicate declaration of identifier in same scope: x" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_expr_binary.py b/src/test/data/pa2/sample/bad_expr_binary.py new file mode 100644 index 0000000..1668849 --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_binary.py @@ -0,0 +1,13 @@ +1 and 2 +1 or 2 +True - False +True < False +1 + True +False + 0 +1 == True +False != 0 +1 is 1 +True is False +None + None +None == None +None is None diff --git a/src/test/data/pa2/sample/bad_expr_binary.py.ast b/src/test/data/pa2/sample/bad_expr_binary.py.ast new file mode 100644 index 0000000..c55893a --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_binary.py.ast @@ -0,0 +1,239 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 13 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 7 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 1 + }, + "operator" : "and", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 7, 1, 7 ], + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 6 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "value" : 1 + }, + "operator" : "or", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 12 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 1, 3, 4 ], + "value" : true + }, + "operator" : "-", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 8, 3, 12 ], + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 1, 4, 12 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 1, 4, 4 ], + "value" : true + }, + "operator" : "<", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 8, 4, 12 ], + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 8 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 5, 5, 8 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 6, 1, 6, 9 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 6, 1, 6, 5 ], + "value" : false + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 7, 1, 7, 9 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 1, 7, 1 ], + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 9 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 10 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 8, 1, 8, 10 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 8, 1, 8, 5 ], + "value" : false + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 10, 8, 10 ], + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 9, 1, 9, 6 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 1, 9, 1 ], + "value" : 1 + }, + "operator" : "is", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 6, 9, 6 ], + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 13 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 10, 1, 10, 13 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 1, 10, 4 ], + "value" : true + }, + "operator" : "is", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 13 ], + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 11 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 11, 1, 11, 11 ], + "left" : { + "kind" : "NoneLiteral", + "location" : [ 11, 1, 11, 4 ] + }, + "operator" : "+", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 11, 8, 11, 11 ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 12, 1, 12, 12 ], + "left" : { + "kind" : "NoneLiteral", + "location" : [ 12, 1, 12, 4 ] + }, + "operator" : "==", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 12, 9, 12, 12 ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 13, 1, 13, 12 ], + "left" : { + "kind" : "NoneLiteral", + "location" : [ 13, 1, 13, 4 ] + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 13, 9, 13, 12 ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_expr_binary.py.ast.typed b/src/test/data/pa2/sample/bad_expr_binary.py.ast.typed new file mode 100644 index 0000000..851cc92 --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_binary.py.ast.typed @@ -0,0 +1,455 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 13 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 7 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 7 ], + "errorMsg" : "Cannot apply operator `and` on types `int` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "and", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 7, 1, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 6 ], + "errorMsg" : "Cannot apply operator `or` on types `int` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 1, 2, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "or", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 6, 2, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 12 ], + "errorMsg" : "Cannot apply operator `-` on types `bool` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 1, 3, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "operator" : "-", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 8, 3, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 1, 4, 12 ], + "errorMsg" : "Cannot apply operator `<` on types `bool` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 1, 4, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "operator" : "<", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 8, 4, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 8 ], + "errorMsg" : "Cannot apply operator `+` on types `int` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 5, 5, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 6, 1, 6, 9 ], + "errorMsg" : "Cannot apply operator `+` on types `bool` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 6, 1, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 7, 1, 7, 9 ], + "errorMsg" : "Cannot apply operator `==` on types `int` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 10 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 8, 1, 8, 10 ], + "errorMsg" : "Cannot apply operator `!=` on types `bool` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 8, 1, 8, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 10, 8, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 6 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 9, 1, 9, 6 ], + "errorMsg" : "Cannot apply operator `is` on types `int` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "is", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 6, 9, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 13 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 10, 1, 10, 13 ], + "errorMsg" : "Cannot apply operator `is` on types `bool` and `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 1, 10, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "operator" : "is", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 9, 10, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 11 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 11, 1, 11, 11 ], + "errorMsg" : "Cannot apply operator `+` on types `` and ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "left" : { + "kind" : "NoneLiteral", + "location" : [ 11, 1, 11, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "operator" : "+", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 11, 8, 11, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 12, 1, 12, 12 ], + "errorMsg" : "Cannot apply operator `==` on types `` and ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "NoneLiteral", + "location" : [ 12, 1, 12, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "operator" : "==", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 12, 9, 12, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 13, 1, 13, 12 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 13, 1, 13, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "NoneLiteral", + "location" : [ 13, 1, 13, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "operator" : "is", + "right" : { + "kind" : "NoneLiteral", + "location" : [ 13, 9, 13, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 7 ], + "message" : "Cannot apply operator `and` on types `int` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 6 ], + "message" : "Cannot apply operator `or` on types `int` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 12 ], + "message" : "Cannot apply operator `-` on types `bool` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 12 ], + "message" : "Cannot apply operator `<` on types `bool` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 8 ], + "message" : "Cannot apply operator `+` on types `int` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 9 ], + "message" : "Cannot apply operator `+` on types `bool` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 7, 1, 7, 9 ], + "message" : "Cannot apply operator `==` on types `int` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 10 ], + "message" : "Cannot apply operator `!=` on types `bool` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 6 ], + "message" : "Cannot apply operator `is` on types `int` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 10, 1, 10, 13 ], + "message" : "Cannot apply operator `is` on types `bool` and `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 11, 1, 11, 11 ], + "message" : "Cannot apply operator `+` on types `` and ``" + }, { + "kind" : "CompilerError", + "location" : [ 12, 1, 12, 12 ], + "message" : "Cannot apply operator `==` on types `` and ``" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_expr_if.py b/src/test/data/pa2/sample/bad_expr_if.py new file mode 100644 index 0000000..4ae5fbe --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_if.py @@ -0,0 +1,2 @@ +x: int = 0 +x = "Hello" if 2 > 3 else 3 diff --git a/src/test/data/pa2/sample/bad_expr_if.py.ast b/src/test/data/pa2/sample/bad_expr_if.py.ast new file mode 100644 index 0000000..24d9ed3 --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_if.py.ast @@ -0,0 +1,70 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 28 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 2, 1, 2, 27 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "IfExpr", + "location" : [ 2, 5, 2, 27 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 16, 2, 20 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 16, 2, 16 ], + "value" : 2 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 20, 2, 20 ], + "value" : 3 + } + }, + "thenExpr" : { + "kind" : "StringLiteral", + "location" : [ 2, 5, 2, 11 ], + "value" : "Hello" + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 27, 2, 27 ], + "value" : 3 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_expr_if.py.ast.typed b/src/test/data/pa2/sample/bad_expr_if.py.ast.typed new file mode 100644 index 0000000..0da86f1 --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_if.py.ast.typed @@ -0,0 +1,107 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 28 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 2, 1, 2, 27 ], + "errorMsg" : "Expected type `int`; got type `object`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IfExpr", + "location" : [ 2, 5, 2, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 16, 2, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 16, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 20, 2, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, + "thenExpr" : { + "kind" : "StringLiteral", + "location" : [ 2, 5, 2, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 27, 2, 27 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 27 ], + "message" : "Expected type `int`; got type `object`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_expr_unary.py b/src/test/data/pa2/sample/bad_expr_unary.py new file mode 100644 index 0000000..0b113ac --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_unary.py @@ -0,0 +1,4 @@ +not "Bad" +-True +-None +not [] diff --git a/src/test/data/pa2/sample/bad_expr_unary.py.ast b/src/test/data/pa2/sample/bad_expr_unary.py.ast new file mode 100644 index 0000000..7632c06 --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_unary.py.ast @@ -0,0 +1,62 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 7 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 9 ], + "operator" : "not", + "operand" : { + "kind" : "StringLiteral", + "location" : [ 1, 5, 1, 9 ], + "value" : "Bad" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 5 ], + "operator" : "-", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 2, 2, 5 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 3, 1, 3, 5 ], + "operator" : "-", + "operand" : { + "kind" : "NoneLiteral", + "location" : [ 3, 2, 3, 5 ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 6 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 4, 1, 4, 6 ], + "operator" : "not", + "operand" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 6 ], + "elements" : [ ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_expr_unary.py.ast.typed b/src/test/data/pa2/sample/bad_expr_unary.py.ast.typed new file mode 100644 index 0000000..f366c93 --- /dev/null +++ b/src/test/data/pa2/sample/bad_expr_unary.py.ast.typed @@ -0,0 +1,114 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 7 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 9 ], + "errorMsg" : "Cannot apply operator `not` on type `str`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "StringLiteral", + "location" : [ 1, 5, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Bad" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 5 ], + "errorMsg" : "Cannot apply operator `-` on type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 2, 2, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 3, 1, 3, 5 ], + "errorMsg" : "Cannot apply operator `-` on type ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "NoneLiteral", + "location" : [ 3, 2, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 6 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 4, 1, 4, 6 ], + "errorMsg" : "Cannot apply operator `not` on type ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 9 ], + "message" : "Cannot apply operator `not` on type `str`" + }, { + "kind" : "CompilerError", + "location" : [ 2, 1, 2, 5 ], + "message" : "Cannot apply operator `-` on type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 5 ], + "message" : "Cannot apply operator `-` on type ``" + }, { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 6 ], + "message" : "Cannot apply operator `not` on type ``" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_func_def_call.py b/src/test/data/pa2/sample/bad_func_def_call.py new file mode 100644 index 0000000..a929805 --- /dev/null +++ b/src/test/data/pa2/sample/bad_func_def_call.py @@ -0,0 +1,13 @@ +def foo(x:str, y:bool) -> int: + return bar() + +def bar() -> int: + return 1 + +# All of the below are bad calls +foo("Hello") +foo("Hello", False, 3) +foo("Hello", 3) +foo(1, "Hello") +baz() + diff --git a/src/test/data/pa2/sample/bad_func_def_call.py.ast b/src/test/data/pa2/sample/bad_func_def_call.py.ast new file mode 100644 index 0000000..64c0e9d --- /dev/null +++ b/src/test/data/pa2/sample/bad_func_def_call.py.ast @@ -0,0 +1,187 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 12 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 12 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 22 ], + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 9, 5, 9, 11 ], + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 18 ], + "value" : false + }, { + "kind" : "IntegerLiteral", + "location" : [ 9, 21, 9, 21 ], + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 15 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "value" : "Hello" + }, { + "kind" : "IntegerLiteral", + "location" : [ 10, 14, 10, 14 ], + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 15 ], + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 11, 5, 11, 5 ], + "value" : 1 + }, { + "kind" : "StringLiteral", + "location" : [ 11, 8, 11, 14 ], + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 3 ], + "name" : "baz" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_func_def_call.py.ast.typed b/src/test/data/pa2/sample/bad_func_def_call.py.ast.typed new file mode 100644 index 0000000..e9dc647 --- /dev/null +++ b/src/test/data/pa2/sample/bad_func_def_call.py.ast.typed @@ -0,0 +1,336 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 12 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 12 ], + "errorMsg" : "Expected 2 arguments; got 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 22 ], + "errorMsg" : "Expected 2 arguments; got 3", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 9, 5, 9, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, { + "kind" : "IntegerLiteral", + "location" : [ 9, 21, 9, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 15 ], + "errorMsg" : "Expected type `bool`; got type `int` in parameter 1", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "IntegerLiteral", + "location" : [ 10, 14, 10, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 11, 1, 11, 15 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 11, 1, 11, 15 ], + "errorMsg" : "Expected type `str`; got type `int` in parameter 0", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 11, 5, 11, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "StringLiteral", + "location" : [ 11, 8, 11, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 12, 1, 12, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 12, 1, 12, 5 ], + "errorMsg" : "Not a function or class: baz", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 3 ], + "name" : "baz" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 12 ], + "message" : "Expected 2 arguments; got 1" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 22 ], + "message" : "Expected 2 arguments; got 3" + }, { + "kind" : "CompilerError", + "location" : [ 10, 1, 10, 15 ], + "message" : "Expected type `bool`; got type `int` in parameter 1" + }, { + "kind" : "CompilerError", + "location" : [ 11, 1, 11, 15 ], + "message" : "Expected type `str`; got type `int` in parameter 0" + }, { + "kind" : "CompilerError", + "location" : [ 12, 1, 12, 5 ], + "message" : "Not a function or class: baz" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_func_def_return.py b/src/test/data/pa2/sample/bad_func_def_return.py new file mode 100644 index 0000000..efccffb --- /dev/null +++ b/src/test/data/pa2/sample/bad_func_def_return.py @@ -0,0 +1,10 @@ +def foo(x:str, y:bool) -> int: + return None + +def bar() -> bool: + return 1 + +def baz() -> str: + return + +foo("Hello", False) diff --git a/src/test/data/pa2/sample/bad_func_def_return.py.ast b/src/test/data/pa2/sample/bad_func_def_return.py.ast new file mode 100644 index 0000000..e7aaa31 --- /dev/null +++ b/src/test/data/pa2/sample/bad_func_def_return.py.ast @@ -0,0 +1,125 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 15 ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 17 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "name" : "baz" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 16 ], + "className" : "str" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 10 ], + "value" : null + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 10, 14, 10, 18 ], + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_func_def_return.py.ast.typed b/src/test/data/pa2/sample/bad_func_def_return.py.ast.typed new file mode 100644 index 0000000..8dafad8 --- /dev/null +++ b/src/test/data/pa2/sample/bad_func_def_return.py.ast.typed @@ -0,0 +1,174 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 15 ], + "errorMsg" : "Expected type `int`; got type ``", + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 17 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "errorMsg" : "Expected type `bool`; got type `int`", + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 1, 8, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 7 ], + "name" : "baz" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 14, 7, 16 ], + "className" : "str" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 10 ], + "errorMsg" : "Expected type `str`; got `None`", + "value" : null + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 10, 5, 10, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 10, 14, 10, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 5, 2, 15 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 5, 5, 5, 12 ], + "message" : "Expected type `bool`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 10 ], + "message" : "Expected type `str`; got `None`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_list_assign.py b/src/test/data/pa2/sample/bad_list_assign.py new file mode 100644 index 0000000..f85c242 --- /dev/null +++ b/src/test/data/pa2/sample/bad_list_assign.py @@ -0,0 +1,6 @@ +x:[int] = None +y:[object] = None + +x = [1, 2, 3] +y = x +y = [1] diff --git a/src/test/data/pa2/sample/bad_list_assign.py.ast b/src/test/data/pa2/sample/bad_list_assign.py.ast new file mode 100644 index 0000000..5fa5dd5 --- /dev/null +++ b/src/test/data/pa2/sample/bad_list_assign.py.ast @@ -0,0 +1,116 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 12, 4, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 7 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_list_assign.py.ast.typed b/src/test/data/pa2/sample/bad_list_assign.py.ast.typed new file mode 100644 index 0000000..b07e2b3 --- /dev/null +++ b/src/test/data/pa2/sample/bad_list_assign.py.ast.typed @@ -0,0 +1,192 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 12, 4, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "Expected type `[object]`; got type `[int]`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 7 ], + "errorMsg" : "Expected type `[object]`; got type `[int]`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 7 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "Expected type `[object]`; got type `[int]`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 7 ], + "message" : "Expected type `[object]`; got type `[int]`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_list_index.py b/src/test/data/pa2/sample/bad_list_index.py new file mode 100644 index 0000000..7b0c708 --- /dev/null +++ b/src/test/data/pa2/sample/bad_list_index.py @@ -0,0 +1,7 @@ +x:[int] = None + +x = [1, 2, 3] +x[True] # Bad +False[0] # Bad +[][0] # Bad +x[True] = x[False] = 1 diff --git a/src/test/data/pa2/sample/bad_list_index.py.ast b/src/test/data/pa2/sample/bad_list_index.py.ast new file mode 100644 index 0000000..b805e51 --- /dev/null +++ b/src/test/data/pa2/sample/bad_list_index.py.ast @@ -0,0 +1,147 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 23 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 1, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 3, 5, 3, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 6, 3, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 12, 3, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 1, 4, 7 ], + "list" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 3, 4, 6 ], + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 5, 1, 5, 8 ], + "list" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 1, 5, 5 ], + "value" : false + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 7, 5, 7 ], + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 5 ], + "list" : { + "kind" : "ListExpr", + "location" : [ 6, 1, 6, 2 ], + "elements" : [ ] + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 4, 6, 4 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 22 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 7 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 3, 7, 6 ], + "value" : true + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 11, 7, 18 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 11, 7, 11 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 17 ], + "value" : false + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 22, 7, 22 ], + "value" : 1 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_list_index.py.ast.typed b/src/test/data/pa2/sample/bad_list_index.py.ast.typed new file mode 100644 index 0000000..fa390f3 --- /dev/null +++ b/src/test/data/pa2/sample/bad_list_index.py.ast.typed @@ -0,0 +1,275 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 23 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 1, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 3, 5, 3, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 6, 3, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 12, 3, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 4, 1, 4, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 1, 4, 7 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 3, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 5, 1, 5, 8 ], + "errorMsg" : "Cannot index into type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "list" : { + "kind" : "BooleanLiteral", + "location" : [ 5, 1, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 7, 5, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 5 ], + "errorMsg" : "Cannot index into type ``", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "list" : { + "kind" : "ListExpr", + "location" : [ 6, 1, 6, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 4, 6, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 22 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 7 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 3, 7, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 11, 7, 18 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 11, 7, 11 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 22, 7, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 7 ], + "message" : "Index is of non-integer type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 8 ], + "message" : "Cannot index into type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 5 ], + "message" : "Cannot index into type ``" + }, { + "kind" : "CompilerError", + "location" : [ 7, 1, 7, 7 ], + "message" : "Index is of non-integer type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 7, 11, 7, 18 ], + "message" : "Index is of non-integer type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_local_assign.py b/src/test/data/pa2/sample/bad_local_assign.py new file mode 100644 index 0000000..77f3420 --- /dev/null +++ b/src/test/data/pa2/sample/bad_local_assign.py @@ -0,0 +1,23 @@ +x:int = 1 +y:int = 2 +z:int = 3 + +def foo(x:int) -> object: + y:int = 4 # OK + global z # OK + + def qux() -> int: + y = 1 # Bad, nonlocal not declared + return 0 + + z = 1 # OK + + pass + +def bar(x:int) -> int: + z = 1 # Bad, global not declared + return x + + +foo(1) + diff --git a/src/test/data/pa2/sample/bad_local_assign.py.ast b/src/test/data/pa2/sample/bad_local_assign.py.ast new file mode 100644 index 0000000..ffac6b5 --- /dev/null +++ b/src/test/data/pa2/sample/bad_local_assign.py.ast @@ -0,0 +1,253 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 22, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 15, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 4 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 7, 5, 7, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "name" : "z" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "qux" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 10, 9, 10, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 9 ], + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 13, 10, 13 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "value" : 0 + } + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 13, 5, 13, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 9, 13, 9 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 17, 1, 19, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 9, 17, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 11, 17, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 19, 17, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 18, 5, 18, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 5, 18, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 9, 18, 9 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 19, 12, 19, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 1, 22, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 1, 22, 6 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 5, 22, 5 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_local_assign.py.ast.typed b/src/test/data/pa2/sample/bad_local_assign.py.ast.typed new file mode 100644 index 0000000..ec39de4 --- /dev/null +++ b/src/test/data/pa2/sample/bad_local_assign.py.ast.typed @@ -0,0 +1,330 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 22, 7 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 15, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 9, 5, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 11, 5, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 19, 5, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + }, { + "kind" : "GlobalDecl", + "location" : [ 7, 5, 7, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "name" : "z" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 11, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "qux" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 20 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 10, 9, 10, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 9, 10, 9 ], + "errorMsg" : "Cannot assign to variable that is not explicitly declared in this scope: y", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 13, 10, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 11, 9, 11, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 16, 11, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 13, 5, 13, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 9, 13, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 17, 1, 19, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 7 ], + "name" : "bar" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 17, 9, 17, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 11, 17, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 17, 19, 17, 21 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 18, 5, 18, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 5, 18, 5 ], + "errorMsg" : "Cannot assign to variable that is not explicitly declared in this scope: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 18, 9, 18, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 19, 5, 19, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 19, 12, 19, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 1, 22, 6 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 1, 22, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 22, 5, 22, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 10, 9, 10, 9 ], + "message" : "Cannot assign to variable that is not explicitly declared in this scope: y" + }, { + "kind" : "CompilerError", + "location" : [ 18, 5, 18, 5 ], + "message" : "Cannot assign to variable that is not explicitly declared in this scope: z" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_none_assign.py b/src/test/data/pa2/sample/bad_none_assign.py new file mode 100644 index 0000000..fc0ec3f --- /dev/null +++ b/src/test/data/pa2/sample/bad_none_assign.py @@ -0,0 +1,14 @@ +class A(object): + x:int = 1 + +y:[bool] = None +z:str = "" +a:A = None + +a = A() + +# Cannot assign None to integer/bool/str types +z = None +a.x = None +y[0] = None + diff --git a/src/test/data/pa2/sample/bad_none_assign.py.ast b/src/test/data/pa2/sample/bad_none_assign.py.ast new file mode 100644 index 0000000..a0a1246 --- /dev/null +++ b/src/test/data/pa2/sample/bad_none_assign.py.ast @@ -0,0 +1,187 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 12 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 4, 3, 4, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 4, 4, 4, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 5, 9, 5, 10 ], + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 7, 6, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 8, 5, 8, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 5, 11, 8 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 10 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 12, 1, 12, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 12, 3, 12, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 13, 1, 13, 11 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 13, 1, 13, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 3, 13, 3 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 8, 13, 11 ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_none_assign.py.ast.typed b/src/test/data/pa2/sample/bad_none_assign.py.ast.typed new file mode 100644 index 0000000..2edc3c2 --- /dev/null +++ b/src/test/data/pa2/sample/bad_none_assign.py.ast.typed @@ -0,0 +1,265 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 13, 12 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 4, 3, 4, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 4, 4, 4, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 5, 1, 5, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 1, 5, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 3, 5, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 5, 9, 5, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 6, 7, 6, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 8, 5, 8, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 8 ], + "errorMsg" : "Expected type `str`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 5, 11, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 10 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 12, 1, 12, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 12, 3, 12, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 13, 1, 13, 11 ], + "errorMsg" : "Expected type `bool`; got type ``", + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 13, 1, 13, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 3, 13, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 8, 13, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 11, 1, 11, 8 ], + "message" : "Expected type `str`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 12, 1, 12, 10 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 13, 1, 13, 11 ], + "message" : "Expected type `bool`; got type ``" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_nonlocal_global.py b/src/test/data/pa2/sample/bad_nonlocal_global.py new file mode 100644 index 0000000..98eea5c --- /dev/null +++ b/src/test/data/pa2/sample/bad_nonlocal_global.py @@ -0,0 +1,25 @@ +x:int = 1 +y:int = 2 +z:int = 3 + +def foo() -> object: + global x # OK + nonlocal y # No such nonlocal var + global w # No such global var + global int # No such global var + + z:bool = True # OK + + def bar() -> object: + global x # OK + nonlocal z # OK + nonlocal y # No such nonlocal var + global foo # No such global var + nonlocal bar # No such nonlocal var + + pass + + bar() + +foo() + diff --git a/src/test/data/pa2/sample/bad_nonlocal_global.py.ast b/src/test/data/pa2/sample/bad_nonlocal_global.py.ast new file mode 100644 index 0000000..dce287d --- /dev/null +++ b/src/test/data/pa2/sample/bad_nonlocal_global.py.ast @@ -0,0 +1,229 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 24, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 22, 10 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 14, 5, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 6, 5, 6, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 6, 12, 6, 12 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 7, 5, 7, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 14, 7, 14 ], + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "w" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 14 ], + "name" : "int" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 5, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 5, 11, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 7, 11, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 11, 14, 11, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 13, 5, 20, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 11 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 18, 13, 23 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 14, 9, 14, 16 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 14, 16, 14, 16 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 15, 9, 15, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 18 ], + "name" : "z" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 16, 9, 16, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 18 ], + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 17, 9, 17, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 17, 16, 17, 18 ], + "name" : "foo" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 18, 9, 18, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 18, 18, 18, 20 ], + "name" : "bar" + } + } ], + "statements" : [ ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 5, 22, 9 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 9 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 7 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 24, 1, 24, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 24, 1, 24, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 24, 1, 24, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_nonlocal_global.py.ast.typed b/src/test/data/pa2/sample/bad_nonlocal_global.py.ast.typed new file mode 100644 index 0000000..3b80c08 --- /dev/null +++ b/src/test/data/pa2/sample/bad_nonlocal_global.py.ast.typed @@ -0,0 +1,259 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 24, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 2 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 3 + } + }, { + "kind" : "FuncDef", + "location" : [ 5, 1, 22, 10 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 14, 5, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 6, 5, 6, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 6, 12, 6, 12 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 7, 5, 7, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 7, 14, 7, 14 ], + "errorMsg" : "Not a nonlocal variable: y", + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 8, 5, 8, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "errorMsg" : "Not a global variable: w", + "name" : "w" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 9, 5, 9, 14 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 9, 12, 9, 14 ], + "errorMsg" : "Not a global variable: int", + "name" : "int" + } + }, { + "kind" : "VarDef", + "location" : [ 11, 5, 11, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 5, 11, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 7, 11, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 11, 14, 11, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 13, 5, 20, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 13, 9, 13, 11 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 13, 18, 13, 23 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 14, 9, 14, 16 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 14, 16, 14, 16 ], + "name" : "x" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 15, 9, 15, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 18 ], + "name" : "z" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 16, 9, 16, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 16, 18, 16, 18 ], + "errorMsg" : "Not a nonlocal variable: y", + "name" : "y" + } + }, { + "kind" : "GlobalDecl", + "location" : [ 17, 9, 17, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 17, 16, 17, 18 ], + "errorMsg" : "Not a global variable: foo", + "name" : "foo" + } + }, { + "kind" : "NonLocalDecl", + "location" : [ 18, 9, 18, 20 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 18, 18, 18, 20 ], + "errorMsg" : "Not a nonlocal variable: bar", + "name" : "bar" + } + } ], + "statements" : [ ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 22, 5, 22, 9 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 9 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 7 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 24, 1, 24, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 24, 1, 24, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 24, 1, 24, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 7, 14, 7, 14 ], + "message" : "Not a nonlocal variable: y" + }, { + "kind" : "CompilerError", + "location" : [ 8, 12, 8, 12 ], + "message" : "Not a global variable: w" + }, { + "kind" : "CompilerError", + "location" : [ 9, 12, 9, 14 ], + "message" : "Not a global variable: int" + }, { + "kind" : "CompilerError", + "location" : [ 16, 18, 16, 18 ], + "message" : "Not a nonlocal variable: y" + }, { + "kind" : "CompilerError", + "location" : [ 17, 16, 17, 18 ], + "message" : "Not a global variable: foo" + }, { + "kind" : "CompilerError", + "location" : [ 18, 18, 18, 20 ], + "message" : "Not a nonlocal variable: bar" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_return_missing.py b/src/test/data/pa2/sample/bad_return_missing.py new file mode 100644 index 0000000..9200f93 --- /dev/null +++ b/src/test/data/pa2/sample/bad_return_missing.py @@ -0,0 +1,6 @@ +def foo() -> int: + if True: + return 1 + # Bad: all paths MUST return int + +foo() diff --git a/src/test/data/pa2/sample/bad_return_missing.py.ast b/src/test/data/pa2/sample/bad_return_missing.py.ast new file mode 100644 index 0000000..8efc035 --- /dev/null +++ b/src/test/data/pa2/sample/bad_return_missing.py.ast @@ -0,0 +1,58 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 6, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 14, 1, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 2, 5, 6, 0 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 8, 2, 11 ], + "value" : true + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "value" : 1 + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 6, 1, 6, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_return_missing.py.ast.typed b/src/test/data/pa2/sample/bad_return_missing.py.ast.typed new file mode 100644 index 0000000..627d4f3 --- /dev/null +++ b/src/test/data/pa2/sample/bad_return_missing.py.ast.typed @@ -0,0 +1,63 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 6, 6 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 6, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "errorMsg" : "All paths in this function/method must have a return statement: foo", + "name" : "foo" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 14, 1, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 2, 5, 6, 0 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 8, 2, 11 ], + "value" : true + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 9, 3, 16 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 16, 3, 16 ], + "value" : 1 + } + } ], + "elseBody" : [ ] + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 6, 1, 6, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 6, 1, 6, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 3 ], + "name" : "foo" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 5, 1, 7 ], + "message" : "All paths in this function/method must have a return statement: foo" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_return_top.py b/src/test/data/pa2/sample/bad_return_top.py new file mode 100644 index 0000000..ca0d0e0 --- /dev/null +++ b/src/test/data/pa2/sample/bad_return_top.py @@ -0,0 +1,3 @@ +x:int = 0 + +return x diff --git a/src/test/data/pa2/sample/bad_return_top.py.ast b/src/test/data/pa2/sample/bad_return_top.py.ast new file mode 100644 index 0000000..992907a --- /dev/null +++ b/src/test/data/pa2/sample/bad_return_top.py.ast @@ -0,0 +1,41 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 1, 3, 8 ], + "value" : { + "kind" : "Identifier", + "location" : [ 3, 8, 3, 8 ], + "name" : "x" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_return_top.py.ast.typed b/src/test/data/pa2/sample/bad_return_top.py.ast.typed new file mode 100644 index 0000000..56df1de --- /dev/null +++ b/src/test/data/pa2/sample/bad_return_top.py.ast.typed @@ -0,0 +1,50 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 3, 1, 3, 8 ], + "errorMsg" : "Return statement cannot appear at the top level", + "value" : { + "kind" : "Identifier", + "location" : [ 3, 8, 3, 8 ], + "name" : "x" + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 3, 1, 3, 8 ], + "message" : "Return statement cannot appear at the top level" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_shadow_local.py b/src/test/data/pa2/sample/bad_shadow_local.py new file mode 100644 index 0000000..9fc916b --- /dev/null +++ b/src/test/data/pa2/sample/bad_shadow_local.py @@ -0,0 +1,14 @@ +class A(object): + x:int = 1 + +def foo(x:int, bool:str) -> object: # Second param uses an invalid name + y:int = 4 # OK + A:int = 5 # Invalid name + object:str = "" # Invalid name + + def str() -> bool: # Invalid name + return False + + pass + +pass diff --git a/src/test/data/pa2/sample/bad_shadow_local.py.ast b/src/test/data/pa2/sample/bad_shadow_local.py.ast new file mode 100644 index 0000000..cff93dc --- /dev/null +++ b/src/test/data/pa2/sample/bad_shadow_local.py.ast @@ -0,0 +1,179 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 14, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 9, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 16, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 19 ], + "name" : "bool" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 34 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 5, 5, 5, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 5, 5, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 7, 5, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 13, 5, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 5 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 10 ], + "name" : "object" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 12, 7, 14 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 7, 18, 7, 19 ], + "value" : "" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "name" : "str" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 21 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 20 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 16, 10, 20 ], + "value" : false + } + } ] + } ], + "statements" : [ ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_shadow_local.py.ast.typed b/src/test/data/pa2/sample/bad_shadow_local.py.ast.typed new file mode 100644 index 0000000..3cc9b9b --- /dev/null +++ b/src/test/data/pa2/sample/bad_shadow_local.py.ast.typed @@ -0,0 +1,199 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 14, 5 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 12, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 9, 4, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 11, 4, 13 ], + "className" : "int" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 16, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 16, 4, 19 ], + "errorMsg" : "Cannot shadow class name: bool", + "name" : "bool" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "str" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 34 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 5, 5, 5, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 5, 5, 5, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 7, 5, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 13, 5, 13 ], + "value" : 4 + } + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "errorMsg" : "Cannot shadow class name: A", + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 5 + } + }, { + "kind" : "VarDef", + "location" : [ 7, 5, 7, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 7, 5, 7, 14 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 10 ], + "errorMsg" : "Cannot shadow class name: object", + "name" : "object" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 12, 7, 14 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 7, 18, 7, 19 ], + "value" : "" + } + }, { + "kind" : "FuncDef", + "location" : [ 9, 5, 10, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 11 ], + "errorMsg" : "Cannot shadow class name: str", + "name" : "str" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 9, 18, 9, 21 ], + "className" : "bool" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 20 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 10, 16, 10, 20 ], + "value" : false + } + } ] + } ], + "statements" : [ ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 16, 4, 19 ], + "message" : "Cannot shadow class name: bool" + }, { + "kind" : "CompilerError", + "location" : [ 6, 5, 6, 5 ], + "message" : "Cannot shadow class name: A" + }, { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 10 ], + "message" : "Cannot shadow class name: object" + }, { + "kind" : "CompilerError", + "location" : [ 9, 9, 9, 11 ], + "message" : "Cannot shadow class name: str" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_shadow_local_2.py b/src/test/data/pa2/sample/bad_shadow_local_2.py new file mode 100644 index 0000000..67a327e --- /dev/null +++ b/src/test/data/pa2/sample/bad_shadow_local_2.py @@ -0,0 +1,8 @@ +def foo(x:int) -> object: + A:int = 5 # Invalid name + pass + +class A(object): + x:int = 1 + +pass diff --git a/src/test/data/pa2/sample/bad_shadow_local_2.py.ast b/src/test/data/pa2/sample/bad_shadow_local_2.py.ast new file mode 100644 index 0000000..5eb5b2e --- /dev/null +++ b/src/test/data/pa2/sample/bad_shadow_local_2.py.ast @@ -0,0 +1,98 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 5 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 3, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 19, 1, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 5 + } + } ], + "statements" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 5, 1, 6, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 7, 5, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_shadow_local_2.py.ast.typed b/src/test/data/pa2/sample/bad_shadow_local_2.py.ast.typed new file mode 100644 index 0000000..ff6ef1b --- /dev/null +++ b/src/test/data/pa2/sample/bad_shadow_local_2.py.ast.typed @@ -0,0 +1,103 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 5 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 3, 9 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 19, 1, 24 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "errorMsg" : "Cannot shadow class name: A", + "name" : "A" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 5 + } + } ], + "statements" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 5, 1, 6, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 7, 5, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 1 + } + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 2, 5, 2, 5 ], + "message" : "Cannot shadow class name: A" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_strings.py b/src/test/data/pa2/sample/bad_strings.py new file mode 100644 index 0000000..86e0e16 --- /dev/null +++ b/src/test/data/pa2/sample/bad_strings.py @@ -0,0 +1,10 @@ +x:str = "Hello" +y:str = "World" +z:str = "" + +1 + x +z = x + 1 +z = x[0] = y +x[1] = y +x[True] + diff --git a/src/test/data/pa2/sample/bad_strings.py.ast b/src/test/data/pa2/sample/bad_strings.py.ast new file mode 100644 index 0000000..04473bf --- /dev/null +++ b/src/test/data/pa2/sample/bad_strings.py.ast @@ -0,0 +1,183 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "value" : "" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 5 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 6, 5, 6, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "z" + }, { + "kind" : "IndexExpr", + "location" : [ 7, 5, 7, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 7, 7, 7 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "name" : "y" + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 8, 1, 8, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 3, 8, 3 ], + "value" : 1 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 8, 8, 8 ], + "name" : "y" + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 9, 1, 9, 7 ], + "list" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 3, 9, 6 ], + "value" : true + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_strings.py.ast.typed b/src/test/data/pa2/sample/bad_strings.py.ast.typed new file mode 100644 index 0000000..f6f2fbe --- /dev/null +++ b/src/test/data/pa2/sample/bad_strings.py.ast.typed @@ -0,0 +1,301 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 8 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 5, 1, 5, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "Cannot apply operator `+` on types `int` and `str`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 9 ], + "errorMsg" : "Expected type `str`; got type `int`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 6, 5, 6, 9 ], + "errorMsg" : "Cannot apply operator `+` on types `str` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + }, { + "kind" : "IndexExpr", + "location" : [ 7, 5, 7, 8 ], + "errorMsg" : "`str` is not a list type", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 7, 7, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 12, 7, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 8, 1, 8, 4 ], + "errorMsg" : "`str` is not a list type", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 8, 3, 8, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 8, 8, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 7 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 9, 1, 9, 7 ], + "errorMsg" : "Index is of non-integer type `bool`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 3, 9, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "Cannot apply operator `+` on types `int` and `str`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 5, 6, 9 ], + "message" : "Cannot apply operator `+` on types `str` and `int`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 9 ], + "message" : "Expected type `str`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 8 ], + "message" : "`str` is not a list type" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 4 ], + "message" : "`str` is not a list type" + }, { + "kind" : "CompilerError", + "location" : [ 9, 1, 9, 7 ], + "message" : "Index is of non-integer type `bool`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_type_annotation.py b/src/test/data/pa2/sample/bad_type_annotation.py new file mode 100644 index 0000000..a25abb6 --- /dev/null +++ b/src/test/data/pa2/sample/bad_type_annotation.py @@ -0,0 +1,7 @@ +x:A = None + +def foo(x:B) -> C: + y:D = None + return + +pass diff --git a/src/test/data/pa2/sample/bad_type_annotation.py.ast b/src/test/data/pa2/sample/bad_type_annotation.py.ast new file mode 100644 index 0000000..e42cf91 --- /dev/null +++ b/src/test/data/pa2/sample/bad_type_annotation.py.ast @@ -0,0 +1,86 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 7, 1, 10 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 5, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 11, 3, 11 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 17, 3, 17 ], + "className" : "C" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 7, 4, 7 ], + "className" : "D" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 11, 4, 14 ] + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 10 ], + "value" : null + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_type_annotation.py.ast.typed b/src/test/data/pa2/sample/bad_type_annotation.py.ast.typed new file mode 100644 index 0000000..221ad45 --- /dev/null +++ b/src/test/data/pa2/sample/bad_type_annotation.py.ast.typed @@ -0,0 +1,106 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 5 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 3 ], + "errorMsg" : "Invalid type annotation; there is no class named: A", + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 7, 1, 10 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 3, 1, 5, 11 ], + "name" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 3, 9, 3, 11 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 11, 3, 11 ], + "errorMsg" : "Invalid type annotation; there is no class named: B", + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 3, 17, 3, 17 ], + "errorMsg" : "Invalid type annotation; there is no class named: C", + "className" : "C" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 7, 4, 7 ], + "errorMsg" : "Invalid type annotation; there is no class named: D", + "className" : "D" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 11, 4, 14 ] + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 10 ], + "value" : null + } ] + } ], + "statements" : [ ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 3, 1, 3 ], + "message" : "Invalid type annotation; there is no class named: A" + }, { + "kind" : "CompilerError", + "location" : [ 3, 11, 3, 11 ], + "message" : "Invalid type annotation; there is no class named: B" + }, { + "kind" : "CompilerError", + "location" : [ 3, 17, 3, 17 ], + "message" : "Invalid type annotation; there is no class named: C" + }, { + "kind" : "CompilerError", + "location" : [ 4, 7, 4, 7 ], + "message" : "Invalid type annotation; there is no class named: D" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_type_id.py b/src/test/data/pa2/sample/bad_type_id.py new file mode 100644 index 0000000..0f931fb --- /dev/null +++ b/src/test/data/pa2/sample/bad_type_id.py @@ -0,0 +1 @@ +x - 1 diff --git a/src/test/data/pa2/sample/bad_type_id.py.ast b/src/test/data/pa2/sample/bad_type_id.py.ast new file mode 100644 index 0000000..ff5c46d --- /dev/null +++ b/src/test/data/pa2/sample/bad_type_id.py.ast @@ -0,0 +1,29 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "left" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_type_id.py.ast.typed b/src/test/data/pa2/sample/bad_type_id.py.ast.typed new file mode 100644 index 0000000..5200116 --- /dev/null +++ b/src/test/data/pa2/sample/bad_type_id.py.ast.typed @@ -0,0 +1,51 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "errorMsg" : "Cannot apply operator `-` on types `object` and `int`", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "errorMsg" : "Not a variable: x", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 1 ], + "message" : "Not a variable: x" + }, { + "kind" : "CompilerError", + "location" : [ 1, 1, 1, 5 ], + "message" : "Cannot apply operator `-` on types `object` and `int`" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_var_assign.py b/src/test/data/pa2/sample/bad_var_assign.py new file mode 100644 index 0000000..a383775 --- /dev/null +++ b/src/test/data/pa2/sample/bad_var_assign.py @@ -0,0 +1,8 @@ +x:int = 1 +y:bool = True + +x = False +y = 2 +z = 3 +x = z = 4 +x = z = None diff --git a/src/test/data/pa2/sample/bad_var_assign.py.ast b/src/test/data/pa2/sample/bad_var_assign.py.ast new file mode 100644 index 0000000..6dabcbd --- /dev/null +++ b/src/test/data/pa2/sample/bad_var_assign.py.ast @@ -0,0 +1,127 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "value" : true + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 5, 4, 9 ], + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 5, 5, 5 ], + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 9, 7, 9 ], + "value" : 4 + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/bad_var_assign.py.ast.typed b/src/test/data/pa2/sample/bad_var_assign.py.ast.typed new file mode 100644 index 0000000..d8217b8 --- /dev/null +++ b/src/test/data/pa2/sample/bad_var_assign.py.ast.typed @@ -0,0 +1,213 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 13 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 9 ], + "errorMsg" : "Expected type `int`; got type `bool`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 4, 5, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 5 ], + "errorMsg" : "Expected type `bool`; got type `int`", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "y" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "errorMsg" : "Not a variable: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "errorMsg" : "Not a variable: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 9, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 12 ], + "errorMsg" : "Expected type `int`; got type ``", + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 8, 5, 8, 5 ], + "errorMsg" : "Not a variable: z", + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "z" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 8, 9, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 4, 1, 4, 9 ], + "message" : "Expected type `int`; got type `bool`" + }, { + "kind" : "CompilerError", + "location" : [ 5, 1, 5, 5 ], + "message" : "Expected type `bool`; got type `int`" + }, { + "kind" : "CompilerError", + "location" : [ 6, 1, 6, 1 ], + "message" : "Not a variable: z" + }, { + "kind" : "CompilerError", + "location" : [ 7, 5, 7, 5 ], + "message" : "Not a variable: z" + }, { + "kind" : "CompilerError", + "location" : [ 8, 1, 8, 12 ], + "message" : "Expected type `int`; got type ``" + }, { + "kind" : "CompilerError", + "location" : [ 8, 5, 8, 5 ], + "message" : "Not a variable: z" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_assign.py b/src/test/data/pa2/sample/class_def_assign.py new file mode 100644 index 0000000..44459ff --- /dev/null +++ b/src/test/data/pa2/sample/class_def_assign.py @@ -0,0 +1,18 @@ +class A(object): + x:int = 1 + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + +a:A = None +b:B = None +c:C = None + +a = A() +a = B() +b = a = c = C() +c = None diff --git a/src/test/data/pa2/sample/class_def_assign.py.ast b/src/test/data/pa2/sample/class_def_assign.py.ast new file mode 100644 index 0000000..92ae3a1 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_assign.py.ast @@ -0,0 +1,263 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 9 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "b" + }, { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "a" + }, { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 13, 17, 15 ], + "function" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 13 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 18, 1, 18, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 5, 18, 8 ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_assign.py.ast.typed b/src/test/data/pa2/sample/class_def_assign.py.ast.typed new file mode 100644 index 0000000..e012a95 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_assign.py.ast.typed @@ -0,0 +1,323 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 18, 9 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, { + "kind" : "Identifier", + "location" : [ 17, 9, 17, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 13, 17, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 17, 13, 17, 13 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 18, 1, 18, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 5, 18, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_attr.py b/src/test/data/pa2/sample/class_def_attr.py new file mode 100644 index 0000000..9a5d948 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_attr.py @@ -0,0 +1,22 @@ +class A(object): + x:int = 1 + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() + +a.x = 1 +b.x = a.x +c.z = a.x == b.x + diff --git a/src/test/data/pa2/sample/class_def_attr.py.ast b/src/test/data/pa2/sample/class_def_attr.py.ast new file mode 100644 index 0000000..b4dcc19 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_attr.py.ast @@ -0,0 +1,346 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 21, 17 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 19, 1, 19, 7 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 19, 1, 19, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 3, 19, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 19, 7, 19, 7 ], + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 20, 1, 20, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 1, 20, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 1 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 3, 20, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 20, 7, 20, 9 ], + "object" : { + "kind" : "Identifier", + "location" : [ 20, 7, 20, 7 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 9, 20, 9 ], + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 16 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 21, 1, 21, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 3, 21, 3 ], + "name" : "z" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 21, 7, 21, 16 ], + "left" : { + "kind" : "MemberExpr", + "location" : [ 21, 7, 21, 9 ], + "object" : { + "kind" : "Identifier", + "location" : [ 21, 7, 21, 7 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 9 ], + "name" : "x" + } + }, + "operator" : "==", + "right" : { + "kind" : "MemberExpr", + "location" : [ 21, 14, 21, 16 ], + "object" : { + "kind" : "Identifier", + "location" : [ 21, 14, 21, 14 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 16, 21, 16 ], + "name" : "x" + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_attr.py.ast.typed b/src/test/data/pa2/sample/class_def_attr.py.ast.typed new file mode 100644 index 0000000..600032c --- /dev/null +++ b/src/test/data/pa2/sample/class_def_attr.py.ast.typed @@ -0,0 +1,446 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 21, 17 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 19, 1, 19, 7 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 19, 1, 19, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 19, 3, 19, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 19, 7, 19, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 20, 1, 20, 9 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 20, 1, 20, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 3, 20, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 20, 7, 20, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 20, 7, 20, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 20, 9, 20, 9 ], + "name" : "x" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 16 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 21, 1, 21, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 3, 21, 3 ], + "name" : "z" + } + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 21, 7, 21, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "MemberExpr", + "location" : [ 21, 7, 21, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 21, 7, 21, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 9, 21, 9 ], + "name" : "x" + } + }, + "operator" : "==", + "right" : { + "kind" : "MemberExpr", + "location" : [ 21, 14, 21, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 21, 14, 21, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 21, 16, 21, 16 ], + "name" : "x" + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_init.py b/src/test/data/pa2/sample/class_def_init.py new file mode 100644 index 0000000..733f489 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_init.py @@ -0,0 +1,17 @@ +class A(object): + x:int = 1 + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() diff --git a/src/test/data/pa2/sample/class_def_init.py.ast b/src/test/data/pa2/sample/class_def_init.py.ast new file mode 100644 index 0000000..2cf1bba --- /dev/null +++ b/src/test/data/pa2/sample/class_def_init.py.ast @@ -0,0 +1,243 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 17, 8 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_init.py.ast.typed b/src/test/data/pa2/sample/class_def_init.py.ast.typed new file mode 100644 index 0000000..c2f9d72 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_init.py.ast.typed @@ -0,0 +1,287 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 17, 8 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 2, 14 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 4, 1, 8, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 7, 4, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 5, 5, 6, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 5, 18, 5, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 5, 24, 5, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 5, 28, 5, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 8, 1, 9, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 7, 8, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 9, 5, 9, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 9, 5, 9, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 9, 7, 9, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 9, 14, 9, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 11, 1, 11, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 11, 1, 11, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 11, 3, 11, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 11, 7, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 12, 1, 12, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 1, 12, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 3, 12, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 12, 7, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 13, 1, 13, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 1, 13, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 1, 13, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 3, 13, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 13, 7, 13, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 1, 15, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 15, 1, 15, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 15, 5, 15, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 15, 5, 15, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 16, 1, 16, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 16, 1, 16, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 16, 5, 16, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 16, 5, 16, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 17, 1, 17, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 17, 5, 17, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 17, 5, 17, 5 ], + "name" : "C" + }, + "args" : [ ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_methods.py b/src/test/data/pa2/sample/class_def_methods.py new file mode 100644 index 0000000..a8d70f1 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_methods.py @@ -0,0 +1,28 @@ +class A(object): + x:int = 1 + + def get_A(self: "A") -> int: + return self.x + +class B(A): + def __init__(self: "B"): + pass + +class C(B): + z:bool = True + + def set_A(self: "C", val: int) -> object: + self.x = val + +a:A = None +b:B = None +c:C = None + +a = A() +b = B() +c = C() + +b.x = a.get_A() +a.x = b.get_A() +c.set_A(0) + diff --git a/src/test/data/pa2/sample/class_def_methods.py.ast b/src/test/data/pa2/sample/class_def_methods.py.ast new file mode 100644 index 0000000..2ddc48e --- /dev/null +++ b/src/test/data/pa2/sample/class_def_methods.py.ast @@ -0,0 +1,451 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 27, 11 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ] + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 25, 1, 25, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 7, 25, 15 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 7, 25, 13 ], + "object" : { + "kind" : "Identifier", + "location" : [ 25, 7, 25, 7 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 26, 1, 26, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 3 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 7, 26, 15 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 7, 26, 13 ], + "object" : { + "kind" : "Identifier", + "location" : [ 26, 7, 26, 7 ], + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 9, 26, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 10 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 27, 9, 27, 9 ], + "value" : 0 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/class_def_methods.py.ast.typed b/src/test/data/pa2/sample/class_def_methods.py.ast.typed new file mode 100644 index 0000000..1f58660 --- /dev/null +++ b/src/test/data/pa2/sample/class_def_methods.py.ast.typed @@ -0,0 +1,595 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 27, 11 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 1, 1, 7, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 7, 1, 7 ], + "name" : "A" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 14 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 2, 5, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 5, 2, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 5, 2, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 7, 2, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 13, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 22 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 13 ], + "name" : "get_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 4, 15, 4, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 15, 4, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 21, 4, 23 ], + "className" : "A" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 29, 4, 31 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 21 ], + "value" : { + "kind" : "MemberExpr", + "location" : [ 5, 16, 5, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 21, 5, 21 ], + "name" : "x" + } + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 7, 1, 11, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 7, 7, 7 ], + "name" : "B" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "A" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 8, 5, 9, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 16 ], + "name" : "__init__" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 18, 8, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 18, 8, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 24, 8, 26 ], + "className" : "B" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 28, 8, 28 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 17, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 7 ], + "name" : "C" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 9, 11, 9 ], + "name" : "B" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 7, 12, 10 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 12, 14, 12, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "FuncDef", + "location" : [ 14, 5, 15, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 9, 14, 13 ], + "name" : "set_A" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 14, 15, 14, 23 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 18 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 21, 14, 23 ], + "className" : "C" + } + }, { + "kind" : "TypedVar", + "location" : [ 14, 26, 14, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 14, 26, 14, 28 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 14, 31, 14, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 14, 39, 14, 44 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 15, 9, 15, 20 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 15, 9, 15, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 15, 9, 15, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 15, 14, 15, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 15, 18, 15, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "val" + } + } ] + } ] + }, { + "kind" : "VarDef", + "location" : [ 17, 1, 17, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 17, 1, 17, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 17, 1, 17, 1 ], + "name" : "a" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 17, 3, 17, 3 ], + "className" : "A" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 17, 7, 17, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 1 ], + "name" : "b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 3, 18, 3 ], + "className" : "B" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 18, 7, 18, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 3 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 1 ], + "name" : "c" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 3, 19, 3 ], + "className" : "C" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 19, 7, 19, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 21, 1, 21, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 21, 1, 21, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 21, 5, 21, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 21, 5, 21, 5 ], + "name" : "A" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 22, 1, 22, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 22, 5, 22, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 22, 5, 22, 5 ], + "name" : "B" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 23, 1, 23, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 23, 5, 23, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 23, 5, 23, 5 ], + "name" : "C" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 25, 1, 25, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 25, 1, 25, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 25, 1, 25, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 3, 25, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 25, 7, 25, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 25, 7, 25, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 25, 7, 25, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 25, 9, 25, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 26, 1, 26, 15 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 26, 1, 26, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "object" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A" + }, + "name" : "a" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 3, 26, 3 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 26, 7, 26, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 26, 7, 26, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 26, 7, 26, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B" + }, + "name" : "b" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 26, 9, 26, 13 ], + "name" : "get_A" + } + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 27, 1, 27, 10 ], + "expr" : { + "kind" : "MethodCallExpr", + "location" : [ 27, 1, 27, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "method" : { + "kind" : "MemberExpr", + "location" : [ 27, 1, 27, 7 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "C" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "object" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C" + }, + "name" : "c" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 27, 3, 27, 7 ], + "name" : "set_A" + } + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 27, 9, 27, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/decl_global_forward.py b/src/test/data/pa2/sample/decl_global_forward.py new file mode 100644 index 0000000..b364535 --- /dev/null +++ b/src/test/data/pa2/sample/decl_global_forward.py @@ -0,0 +1,9 @@ +def set_x() -> int: + global x + x = 1 + return x + +x:int = 0 + +set_x() +print(x) diff --git a/src/test/data/pa2/sample/decl_global_forward.py.ast b/src/test/data/pa2/sample/decl_global_forward.py.ast new file mode 100644 index 0000000..a450fe6 --- /dev/null +++ b/src/test/data/pa2/sample/decl_global_forward.py.ast @@ -0,0 +1,108 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 9 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 4, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "set_x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 2, 5, 2, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 12 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 12 ], + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 7 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 7 ], + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 5 ], + "name" : "set_x" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 8 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 8 ], + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 9, 7, 9, 7 ], + "name" : "x" + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/decl_global_forward.py.ast.typed b/src/test/data/pa2/sample/decl_global_forward.py.ast.typed new file mode 100644 index 0000000..4d32ce7 --- /dev/null +++ b/src/test/data/pa2/sample/decl_global_forward.py.ast.typed @@ -0,0 +1,155 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 9 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 4, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "set_x" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 2, 5, 2, 12 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 12 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 4, 5, 4, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 4, 12, 4, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 1, 6, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 1, 6, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 3, 6, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 8, 1, 8, 7 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 8, 1, 8, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "set_x" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 9, 1, 9, 8 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 9, 1, 9, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 9, 7, 9, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/decl_nonlocal_forward.py b/src/test/data/pa2/sample/decl_nonlocal_forward.py new file mode 100644 index 0000000..b1ff307 --- /dev/null +++ b/src/test/data/pa2/sample/decl_nonlocal_forward.py @@ -0,0 +1,10 @@ +def outer() -> int: + def inner() -> int: + nonlocal x + x = 1 + return x + x:int = 0 + inner() + return x + +print(outer()) diff --git a/src/test/data/pa2/sample/decl_nonlocal_forward.py.ast b/src/test/data/pa2/sample/decl_nonlocal_forward.py.ast new file mode 100644 index 0000000..1b5f11b --- /dev/null +++ b/src/test/data/pa2/sample/decl_nonlocal_forward.py.ast @@ -0,0 +1,137 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 15 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 8, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "outer" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 13 ], + "name" : "inner" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 20, 2, 22 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 3, 9, 3, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 3, 18, 3, 18 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 9, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 16 ], + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 5, 7, 11 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 5, 7, 11 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 9 ], + "name" : "inner" + }, + "args" : [ ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 14 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 5 ], + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 10, 7, 10, 13 ], + "function" : { + "kind" : "Identifier", + "location" : [ 10, 7, 10, 11 ], + "name" : "outer" + }, + "args" : [ ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/decl_nonlocal_forward.py.ast.typed b/src/test/data/pa2/sample/decl_nonlocal_forward.py.ast.typed new file mode 100644 index 0000000..f5781a7 --- /dev/null +++ b/src/test/data/pa2/sample/decl_nonlocal_forward.py.ast.typed @@ -0,0 +1,196 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 10, 15 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 8, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 9 ], + "name" : "outer" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 16, 1, 18 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 2, 5, 5, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 9, 2, 13 ], + "name" : "inner" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 2, 20, 2, 22 ], + "className" : "int" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 3, 9, 3, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 3, 18, 3, 18 ], + "name" : "x" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 9, 4, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "ReturnStmt", + "location" : [ 5, 9, 5, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 16, 5, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + }, { + "kind" : "VarDef", + "location" : [ 6, 5, 6, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 6, 5, 6, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 6, 7, 6, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 13, 6, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 5, 7, 11 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 5, 7, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "inner" + }, + "args" : [ ] + } + }, { + "kind" : "ReturnStmt", + "location" : [ 8, 5, 8, 12 ], + "value" : { + "kind" : "Identifier", + "location" : [ 8, 12, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 10, 1, 10, 14 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 10, 1, 10, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "name" : "print" + }, + "args" : [ { + "kind" : "CallExpr", + "location" : [ 10, 7, 10, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 10, 7, 10, 11 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "outer" + }, + "args" : [ ] + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_binary.py b/src/test/data/pa2/sample/expr_binary.py new file mode 100644 index 0000000..b35b22d --- /dev/null +++ b/src/test/data/pa2/sample/expr_binary.py @@ -0,0 +1,2 @@ +1 + 2 * 3 > 13 // 3 % 2 or 1 != 1 and False == False + diff --git a/src/test/data/pa2/sample/expr_binary.py.ast b/src/test/data/pa2/sample/expr_binary.py.ast new file mode 100644 index 0000000..3e59d31 --- /dev/null +++ b/src/test/data/pa2/sample/expr_binary.py.ast @@ -0,0 +1,109 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 53 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 52 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 52 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 23 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 9 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 5, 1, 9 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 2 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 3 + } + } + }, + "operator" : ">", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 23 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 19 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 14 ], + "value" : 13 + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 19, 1, 19 ], + "value" : 3 + } + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 23, 1, 23 ], + "value" : 2 + } + } + }, + "operator" : "or", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 52 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 33 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 28, 1, 28 ], + "value" : 1 + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 33, 1, 33 ], + "value" : 1 + } + }, + "operator" : "and", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 39, 1, 52 ], + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 39, 1, 43 ], + "value" : false + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 48, 1, 52 ], + "value" : false + } + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_binary.py.ast.typed b/src/test/data/pa2/sample/expr_binary.py.ast.typed new file mode 100644 index 0000000..146d277 --- /dev/null +++ b/src/test/data/pa2/sample/expr_binary.py.ast.typed @@ -0,0 +1,185 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 53 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 52 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "+", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 5, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + } + }, + "operator" : ">", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 13, 1, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 13, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 13 + }, + "operator" : "//", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 19, 1, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, + "operator" : "%", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 23, 1, 23 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + } + }, + "operator" : "or", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BinaryExpr", + "location" : [ 1, 28, 1, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 28, 1, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "!=", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 33, 1, 33 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, + "operator" : "and", + "right" : { + "kind" : "BinaryExpr", + "location" : [ 1, 39, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 39, 1, 43 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "operator" : "==", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 48, 1, 52 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_concat.py b/src/test/data/pa2/sample/expr_concat.py new file mode 100644 index 0000000..68c41a0 --- /dev/null +++ b/src/test/data/pa2/sample/expr_concat.py @@ -0,0 +1,3 @@ +[1, 2] + [3, 4] +"Hello " + "World" +[1, 2] + [True] diff --git a/src/test/data/pa2/sample/expr_concat.py.ast b/src/test/data/pa2/sample/expr_concat.py.ast new file mode 100644 index 0000000..064862b --- /dev/null +++ b/src/test/data/pa2/sample/expr_concat.py.ast @@ -0,0 +1,93 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 16 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 15 ], + "left" : { + "kind" : "ListExpr", + "location" : [ 1, 1, 1, 6 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 10, 1, 15 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 11, 1, 11 ], + "value" : 3 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 14, 1, 14 ], + "value" : 4 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 18 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 18 ], + "left" : { + "kind" : "StringLiteral", + "location" : [ 2, 1, 2, 8 ], + "value" : "Hello " + }, + "operator" : "+", + "right" : { + "kind" : "StringLiteral", + "location" : [ 2, 12, 2, 18 ], + "value" : "World" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 15 ], + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 6 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 2, 3, 2 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 15 ], + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 3, 11, 3, 14 ], + "value" : true + } ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_concat.py.ast.typed b/src/test/data/pa2/sample/expr_concat.py.ast.typed new file mode 100644 index 0000000..4c61b0e --- /dev/null +++ b/src/test/data/pa2/sample/expr_concat.py.ast.typed @@ -0,0 +1,175 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 16 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "left" : { + "kind" : "ListExpr", + "location" : [ 1, 1, 1, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 1, 10, 1, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 1, 11, 1, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + }, { + "kind" : "IntegerLiteral", + "location" : [ 1, 14, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } ] + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 18 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 2, 1, 2, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "left" : { + "kind" : "StringLiteral", + "location" : [ 2, 1, 2, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello " + }, + "operator" : "+", + "right" : { + "kind" : "StringLiteral", + "location" : [ 2, 12, 2, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 15 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "left" : { + "kind" : "ListExpr", + "location" : [ 3, 1, 3, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 2, 3, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 3, 11, 3, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_id.py b/src/test/data/pa2/sample/expr_id.py new file mode 100644 index 0000000..c6fcd80 --- /dev/null +++ b/src/test/data/pa2/sample/expr_id.py @@ -0,0 +1,3 @@ +x:int = 1 + +x - 1 diff --git a/src/test/data/pa2/sample/expr_id.py.ast b/src/test/data/pa2/sample/expr_id.py.ast new file mode 100644 index 0000000..0f6ab04 --- /dev/null +++ b/src/test/data/pa2/sample/expr_id.py.ast @@ -0,0 +1,51 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 5 ], + "left" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_id.py.ast.typed b/src/test/data/pa2/sample/expr_id.py.ast.typed new file mode 100644 index 0000000..cdefa39 --- /dev/null +++ b/src/test/data/pa2/sample/expr_id.py.ast.typed @@ -0,0 +1,67 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 3, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 3, 1, 3, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 3, 1, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "-", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_if.py b/src/test/data/pa2/sample/expr_if.py new file mode 100644 index 0000000..e9e9c26 --- /dev/null +++ b/src/test/data/pa2/sample/expr_if.py @@ -0,0 +1 @@ +3 if 1 > 2 else 4 diff --git a/src/test/data/pa2/sample/expr_if.py.ast b/src/test/data/pa2/sample/expr_if.py.ast new file mode 100644 index 0000000..0ed9a55 --- /dev/null +++ b/src/test/data/pa2/sample/expr_if.py.ast @@ -0,0 +1,43 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 18 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 17 ], + "expr" : { + "kind" : "IfExpr", + "location" : [ 1, 1, 1, 17 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 1, 6, 1, 10 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 6, 1, 6 ], + "value" : 1 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "value" : 2 + } + }, + "thenExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 3 + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 17, 1, 17 ], + "value" : 4 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_if.py.ast.typed b/src/test/data/pa2/sample/expr_if.py.ast.typed new file mode 100644 index 0000000..3aa7a5f --- /dev/null +++ b/src/test/data/pa2/sample/expr_if.py.ast.typed @@ -0,0 +1,67 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 18 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 17 ], + "expr" : { + "kind" : "IfExpr", + "location" : [ 1, 1, 1, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 1, 6, 1, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 6, 1, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 10, 1, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, + "thenExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + }, + "elseExpr" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 17, 1, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_int.py b/src/test/data/pa2/sample/expr_int.py new file mode 100644 index 0000000..f39d689 --- /dev/null +++ b/src/test/data/pa2/sample/expr_int.py @@ -0,0 +1 @@ +6 * 9 diff --git a/src/test/data/pa2/sample/expr_int.py.ast b/src/test/data/pa2/sample/expr_int.py.ast new file mode 100644 index 0000000..2eb3e50 --- /dev/null +++ b/src/test/data/pa2/sample/expr_int.py.ast @@ -0,0 +1,29 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "value" : 6 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "value" : 9 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_int.py.ast.typed b/src/test/data/pa2/sample/expr_int.py.ast.typed new file mode 100644 index 0000000..55a6721 --- /dev/null +++ b/src/test/data/pa2/sample/expr_int.py.ast.typed @@ -0,0 +1,41 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 1, 6 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 5 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 1, 1, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 1, 1, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 6 + }, + "operator" : "*", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 5, 1, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 9 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_list_index.py b/src/test/data/pa2/sample/expr_list_index.py new file mode 100644 index 0000000..b9d97e3 --- /dev/null +++ b/src/test/data/pa2/sample/expr_list_index.py @@ -0,0 +1,12 @@ +x:[int] = None +y:int = 0 +z:[bool] = None +o:object = None + +x = [1, 2, 3] +z = [False, True] + +y = x[0] +x[0] = 1 +z[1] = z[0] +o = x[1] diff --git a/src/test/data/pa2/sample/expr_list_index.py.ast b/src/test/data/pa2/sample/expr_list_index.py.ast new file mode 100644 index 0000000..5cb5c50 --- /dev/null +++ b/src/test/data/pa2/sample/expr_list_index.py.ast @@ -0,0 +1,247 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ] + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 17 ], + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 10 ], + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 16 ], + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 9, 5, 9, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 7, 9, 7 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 10, 1, 10, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 3, 10, 3 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 8, 10, 8 ], + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 11 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 11, 1, 11, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 3, 11, 3 ], + "value" : 1 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 11, 8, 11, 11 ], + "list" : { + "kind" : "Identifier", + "location" : [ 11, 8, 11, 8 ], + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 10, 11, 10 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "o" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 12, 5, 12, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 7, 12, 7 ], + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_list_index.py.ast.typed b/src/test/data/pa2/sample/expr_list_index.py.ast.typed new file mode 100644 index 0000000..28fbe48 --- /dev/null +++ b/src/test/data/pa2/sample/expr_list_index.py.ast.typed @@ -0,0 +1,398 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 9 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 9, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 17 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 7, 6, 7, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 13, 7, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "y" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 9, 5, 9, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 9, 7, 9, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 10, 1, 10, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 3, 10, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 10, 8, 10, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 11 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 11, 1, 11, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 3, 11, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 11, 8, 11, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 11, 8, 11, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 11, 10, 11, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 12, 5, 12, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 7, 12, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_lists.py b/src/test/data/pa2/sample/expr_lists.py new file mode 100644 index 0000000..2268a54 --- /dev/null +++ b/src/test/data/pa2/sample/expr_lists.py @@ -0,0 +1,12 @@ +x:[int] = None +y:[object] = None +z:[bool] = None +o:object = None + +x = [1, 2, 3] +x = [] +y = [1, True] +z = [False, True] +x = None +o = x +o = x = [1] diff --git a/src/test/data/pa2/sample/expr_lists.py.ast b/src/test/data/pa2/sample/expr_lists.py.ast new file mode 100644 index 0000000..5930b97 --- /dev/null +++ b/src/test/data/pa2/sample/expr_lists.py.ast @@ -0,0 +1,233 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 12 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ] + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ] + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 6 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 6 ], + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 8, 5, 8, 13 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 8, 6, 8, 6 ], + "value" : 1 + }, { + "kind" : "BooleanLiteral", + "location" : [ 8, 9, 8, 12 ], + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 5, 9, 17 ], + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 9, 6, 9, 10 ], + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 13, 9, 16 ], + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 10, 5, 10, 8 ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "name" : "o" + }, { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 12, 9, 12, 11 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 12, 10, 12, 10 ], + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_lists.py.ast.typed b/src/test/data/pa2/sample/expr_lists.py.ast.typed new file mode 100644 index 0000000..e8c37bd --- /dev/null +++ b/src/test/data/pa2/sample/expr_lists.py.ast.typed @@ -0,0 +1,374 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 12, 12 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ListType", + "location" : [ 3, 3, 3, 8 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 3, 4, 3, 7 ], + "className" : "bool" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 3, 12, 3, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 6, 5, 6, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 6, 6, 6, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 9, 6, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 6, 12, 6, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 6 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 7, 5, 7, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, + "elements" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 8, 5, 8, 13 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 8, 6, 8, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "BooleanLiteral", + "location" : [ 8, 9, 8, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "name" : "z" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 9, 5, 9, 17 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "bool" + } + }, + "elements" : [ { + "kind" : "BooleanLiteral", + "location" : [ 9, 6, 9, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, { + "kind" : "BooleanLiteral", + "location" : [ 9, 13, 9, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 10, 1, 10, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 10, 1, 10, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "NoneLiteral", + "location" : [ 10, 5, 10, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 11, 1, 11, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 11, 1, 11, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 11, 5, 11, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } + }, { + "kind" : "AssignStmt", + "location" : [ 12, 1, 12, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 12, 1, 12, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + }, { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 5 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 12, 9, 12, 11 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 12, 10, 12, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_unary.py b/src/test/data/pa2/sample/expr_unary.py new file mode 100644 index 0000000..58d9627 --- /dev/null +++ b/src/test/data/pa2/sample/expr_unary.py @@ -0,0 +1,2 @@ +-1 +not False diff --git a/src/test/data/pa2/sample/expr_unary.py.ast b/src/test/data/pa2/sample/expr_unary.py.ast new file mode 100644 index 0000000..4f1abf3 --- /dev/null +++ b/src/test/data/pa2/sample/expr_unary.py.ast @@ -0,0 +1,37 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 10 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 2 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 2 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 9 ], + "operator" : "not", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 5, 2, 9 ], + "value" : false + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_unary.py.ast.typed b/src/test/data/pa2/sample/expr_unary.py.ast.typed new file mode 100644 index 0000000..77b0fd0 --- /dev/null +++ b/src/test/data/pa2/sample/expr_unary.py.ast.typed @@ -0,0 +1,53 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 2, 10 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 1, 1, 1, 2 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 1, 1, 1, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 2, 1, 2 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 2, 1, 2, 9 ], + "expr" : { + "kind" : "UnaryExpr", + "location" : [ 2, 1, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "operator" : "not", + "operand" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 5, 2, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_var_assign.py b/src/test/data/pa2/sample/expr_var_assign.py new file mode 100644 index 0000000..3b8ebfe --- /dev/null +++ b/src/test/data/pa2/sample/expr_var_assign.py @@ -0,0 +1,4 @@ +x:int = 1 +o:object = None + +x = o = 42 diff --git a/src/test/data/pa2/sample/expr_var_assign.py.ast b/src/test/data/pa2/sample/expr_var_assign.py.ast new file mode 100644 index 0000000..5b8093e --- /dev/null +++ b/src/test/data/pa2/sample/expr_var_assign.py.ast @@ -0,0 +1,71 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 11 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "o" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 10 ], + "value" : 42 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/expr_var_assign.py.ast.typed b/src/test/data/pa2/sample/expr_var_assign.py.ast.typed new file mode 100644 index 0000000..950866b --- /dev/null +++ b/src/test/data/pa2/sample/expr_var_assign.py.ast.typed @@ -0,0 +1,91 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 11 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 12, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 42 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/func_def_call.py b/src/test/data/pa2/sample/func_def_call.py new file mode 100644 index 0000000..e5f4e8b --- /dev/null +++ b/src/test/data/pa2/sample/func_def_call.py @@ -0,0 +1,7 @@ +def foo(x:str, y:bool) -> int: + return bar() + +def bar() -> int: + return 1 + +foo("Hello", False) diff --git a/src/test/data/pa2/sample/func_def_call.py.ast b/src/test/data/pa2/sample/func_def_call.py.ast new file mode 100644 index 0000000..b6194bd --- /dev/null +++ b/src/test/data/pa2/sample/func_def_call.py.ast @@ -0,0 +1,111 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 3 ], + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 7, 5, 7, 11 ], + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 14, 7, 18 ], + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/func_def_call.py.ast.typed b/src/test/data/pa2/sample/func_def_call.py.ast.typed new file mode 100644 index 0000000..20e0bde --- /dev/null +++ b/src/test/data/pa2/sample/func_def_call.py.ast.typed @@ -0,0 +1,153 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 20 ], + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 1, 1, 2, 17 ], + "name" : { + "kind" : "Identifier", + "location" : [ 1, 5, 1, 7 ], + "name" : "foo" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 1, 9, 1, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 9, 1, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 11, 1, 13 ], + "className" : "str" + } + }, { + "kind" : "TypedVar", + "location" : [ 1, 16, 1, 21 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 16, 1, 16 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 18, 1, 21 ], + "className" : "bool" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 1, 27, 1, 29 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 2, 5, 2, 16 ], + "value" : { + "kind" : "CallExpr", + "location" : [ 2, 12, 2, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 2, 12, 2, 14 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "bar" + }, + "args" : [ ] + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 4, 1, 5, 13 ], + "name" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 7 ], + "name" : "bar" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 14, 4, 16 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 5, 5, 5, 12 ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 5, 12, 5, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } ] + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 7, 1, 7, 19 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 7, 1, 7, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "function" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "str" + }, { + "kind" : "ClassValueType", + "className" : "bool" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "foo" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 7, 5, 7, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + }, { + "kind" : "BooleanLiteral", + "location" : [ 7, 14, 7, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } ] + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_for_lists.py b/src/test/data/pa2/sample/stmt_for_lists.py new file mode 100644 index 0000000..235fb2f --- /dev/null +++ b/src/test/data/pa2/sample/stmt_for_lists.py @@ -0,0 +1,4 @@ +x:int = 0 + +for x in [1, 2, 3]: + x + 1 diff --git a/src/test/data/pa2/sample/stmt_for_lists.py.ast b/src/test/data/pa2/sample/stmt_for_lists.py.ast new file mode 100644 index 0000000..3e6fb8f --- /dev/null +++ b/src/test/data/pa2/sample/stmt_for_lists.py.ast @@ -0,0 +1,77 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + }, + "iterable" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 11, 3, 11 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 14, 3, 14 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 17, 3, 17 ], + "value" : 3 + } ] + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 5, 4, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_for_lists.py.ast.typed b/src/test/data/pa2/sample/stmt_for_lists.py.ast.typed new file mode 100644 index 0000000..9bd4123 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_for_lists.py.ast.typed @@ -0,0 +1,116 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "iterable" : { + "kind" : "ListExpr", + "location" : [ 3, 10, 3, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 3, 11, 3, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 14, 3, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 3, 17, 3, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } ] + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 4, 5, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_for_strings.py b/src/test/data/pa2/sample/stmt_for_strings.py new file mode 100644 index 0000000..b135f8b --- /dev/null +++ b/src/test/data/pa2/sample/stmt_for_strings.py @@ -0,0 +1,4 @@ +s:str = "Hello" + +for s in s: + s[0] diff --git a/src/test/data/pa2/sample/stmt_for_strings.py.ast b/src/test/data/pa2/sample/stmt_for_strings.py.ast new file mode 100644 index 0000000..6e837a5 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_for_strings.py.ast @@ -0,0 +1,64 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "value" : "Hello" + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "s" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 3, 10, 3, 10 ], + "name" : "s" + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 5, 4, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "s" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 7, 4, 7 ], + "value" : 0 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_for_strings.py.ast.typed b/src/test/data/pa2/sample/stmt_for_strings.py.ast.typed new file mode 100644 index 0000000..0f36ad0 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_for_strings.py.ast.typed @@ -0,0 +1,88 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 5, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + } ], + "statements" : [ { + "kind" : "ForStmt", + "location" : [ 3, 1, 5, 1 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + }, + "iterable" : { + "kind" : "Identifier", + "location" : [ 3, 10, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + }, + "body" : [ { + "kind" : "ExprStmt", + "location" : [ 4, 5, 4, 8 ], + "expr" : { + "kind" : "IndexExpr", + "location" : [ 4, 5, 4, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "s" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 7, 4, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_if.py b/src/test/data/pa2/sample/stmt_if.py new file mode 100644 index 0000000..d5053bf --- /dev/null +++ b/src/test/data/pa2/sample/stmt_if.py @@ -0,0 +1,7 @@ +if False: + pass +elif True: + if 1 == 1: + pass +else: + pass diff --git a/src/test/data/pa2/sample/stmt_if.py.ast b/src/test/data/pa2/sample/stmt_if.py.ast new file mode 100644 index 0000000..48c33f3 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_if.py.ast @@ -0,0 +1,51 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 1 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 1, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 4, 1, 8 ], + "value" : false + }, + "thenBody" : [ ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 3, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 6, 3, 9 ], + "value" : true + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 4, 5, 6, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 4, 8, 4, 13 ], + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 8, 4, 8 ], + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "value" : 1 + } + }, + "thenBody" : [ ], + "elseBody" : [ ] + } ], + "elseBody" : [ ] + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_if.py.ast.typed b/src/test/data/pa2/sample/stmt_if.py.ast.typed new file mode 100644 index 0000000..3453f95 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_if.py.ast.typed @@ -0,0 +1,71 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 8, 1 ], + "declarations" : [ ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 1, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 1, 4, 1, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + }, + "thenBody" : [ ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 3, 1, 8, 1 ], + "condition" : { + "kind" : "BooleanLiteral", + "location" : [ 3, 6, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + }, + "thenBody" : [ { + "kind" : "IfStmt", + "location" : [ 4, 5, 6, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 4, 8, 4, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 8, 4, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 13, 4, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, + "thenBody" : [ ], + "elseBody" : [ ] + } ], + "elseBody" : [ ] + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_list_assign.py b/src/test/data/pa2/sample/stmt_list_assign.py new file mode 100644 index 0000000..34221dd --- /dev/null +++ b/src/test/data/pa2/sample/stmt_list_assign.py @@ -0,0 +1,7 @@ +x:[int] = None +y:[object] = None + +x = [1, 2] +y = [None] +x[0] = 3 +x[1] = y[0] = 4 diff --git a/src/test/data/pa2/sample/stmt_list_assign.py.ast b/src/test/data/pa2/sample/stmt_list_assign.py.ast new file mode 100644 index 0000000..cac7d91 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_list_assign.py.ast @@ -0,0 +1,155 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 16 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ] + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 10 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "value" : 2 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 5, 5, 5, 10 ], + "elements" : [ { + "kind" : "NoneLiteral", + "location" : [ 5, 6, 5, 9 ] + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 3, 6, 3 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 8, 6, 8 ], + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 15 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 4 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "value" : 1 + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 8, 7, 11 ], + "list" : { + "kind" : "Identifier", + "location" : [ 7, 8, 7, 8 ], + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 10, 7, 10 ], + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 15, 7, 15 ], + "value" : 4 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_list_assign.py.ast.typed b/src/test/data/pa2/sample/stmt_list_assign.py.ast.typed new file mode 100644 index 0000000..5fefc31 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_list_assign.py.ast.typed @@ -0,0 +1,256 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 16 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 14 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ListType", + "location" : [ 1, 3, 1, 7 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 1, 4, 1, 6 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 1, 11, 1, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 10 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ListType", + "location" : [ 2, 3, 2, 10 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 2, 4, 2, 9 ], + "className" : "object" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 2, 14, 2, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 4, 1, 4, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 4, 5, 4, 10 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 4, 6, 4, 6 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 4, 9, 4, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 5, 5, 5, 10 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, + "elements" : [ { + "kind" : "NoneLiteral", + "location" : [ 5, 6, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 6, 1, 6, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 3, 6, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 8, 6, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 3 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 15 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 7, 1, 7, 4 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 3, 7, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "IndexExpr", + "location" : [ 7, 8, 7, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 7, 8, 7, 8 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, + "name" : "y" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 10, 7, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 7, 15, 7, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 4 + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_var_assign.py b/src/test/data/pa2/sample/stmt_var_assign.py new file mode 100644 index 0000000..71e9795 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_var_assign.py @@ -0,0 +1,9 @@ +x:int = 1 +y:bool = True +z:str = "" +o:object = None + +x = 2 +y = False +z = "Hello" +o = z diff --git a/src/test/data/pa2/sample/stmt_var_assign.py.ast b/src/test/data/pa2/sample/stmt_var_assign.py.ast new file mode 100644 index 0000000..4a474cd --- /dev/null +++ b/src/test/data/pa2/sample/stmt_var_assign.py.ast @@ -0,0 +1,150 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "value" : true + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ] + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 5, 7, 9 ], + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "value" : "Hello" + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_var_assign.py.ast.typed b/src/test/data/pa2/sample/stmt_var_assign.py.ast.typed new file mode 100644 index 0000000..cb529c2 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_var_assign.py.ast.typed @@ -0,0 +1,198 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 9, 6 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 13 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 6 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 6 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 2, 10, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : true + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + }, { + "kind" : "VarDef", + "location" : [ 4, 1, 4, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 1, 4, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 1, 4, 1 ], + "name" : "o" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 3, 4, 8 ], + "className" : "object" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 4, 12, 4, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "name" : "y" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 7, 5, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false + } + }, { + "kind" : "AssignStmt", + "location" : [ 8, 1, 8, 11 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 1, 8, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 8, 5, 8, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + }, { + "kind" : "AssignStmt", + "location" : [ 9, 1, 9, 5 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 1, 9, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, + "name" : "o" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 5, 9, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_while.py b/src/test/data/pa2/sample/stmt_while.py new file mode 100644 index 0000000..d45a4fc --- /dev/null +++ b/src/test/data/pa2/sample/stmt_while.py @@ -0,0 +1,3 @@ +x:int = 0 +while x < 100: + x = x + 1 diff --git a/src/test/data/pa2/sample/stmt_while.py.ast b/src/test/data/pa2/sample/stmt_while.py.ast new file mode 100644 index 0000000..10ae361 --- /dev/null +++ b/src/test/data/pa2/sample/stmt_while.py.ast @@ -0,0 +1,75 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 2, 1, 4, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 7, 2, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 11, 2, 13 ], + "value" : 100 + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 3, 9, 3, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/stmt_while.py.ast.typed b/src/test/data/pa2/sample/stmt_while.py.ast.typed new file mode 100644 index 0000000..c928a9e --- /dev/null +++ b/src/test/data/pa2/sample/stmt_while.py.ast.typed @@ -0,0 +1,107 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 4, 1 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 9 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 1, 9, 1, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } ], + "statements" : [ { + "kind" : "WhileStmt", + "location" : [ 2, 1, 4, 1 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 2, 7, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "<", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 2, 11, 2, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 100 + } + }, + "body" : [ { + "kind" : "AssignStmt", + "location" : [ 3, 5, 3, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 3, 9, 3, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 3, 9, 3, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 13, 3, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 1 + } + } + } ] + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/strings.py b/src/test/data/pa2/sample/strings.py new file mode 100644 index 0000000..dd6a4ee --- /dev/null +++ b/src/test/data/pa2/sample/strings.py @@ -0,0 +1,8 @@ +x:str = "Hello" +y:str = "World" +z:str = "" + +z = x + y +z = x[0] +x = y = z + diff --git a/src/test/data/pa2/sample/strings.py.ast b/src/test/data/pa2/sample/strings.py.ast new file mode 100644 index 0000000..1ba2f58 --- /dev/null +++ b/src/test/data/pa2/sample/strings.py.ast @@ -0,0 +1,139 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "value" : "" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 5, 5, 5, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "name" : "y" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "name" : "z" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 6, 5, 6, 8 ], + "list" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 7, 6, 7 ], + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/sample/strings.py.ast.typed b/src/test/data/pa2/sample/strings.py.ast.typed new file mode 100644 index 0000000..acff3ae --- /dev/null +++ b/src/test/data/pa2/sample/strings.py.ast.typed @@ -0,0 +1,195 @@ +{ + "kind" : "Program", + "location" : [ 1, 1, 7, 10 ], + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 1, 1, 1, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 1, 1, 1, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 1, 1, 1, 1 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 1, 3, 1, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 1, 9, 1, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "Hello" + } + }, { + "kind" : "VarDef", + "location" : [ 2, 1, 2, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 2, 1, 2, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 2, 1, 2, 1 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 2, 3, 2, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 2, 9, 2, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "World" + } + }, { + "kind" : "VarDef", + "location" : [ 3, 1, 3, 10 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 1, 3, 5 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 1, 3, 1 ], + "name" : "z" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 3, 3, 5 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 3, 9, 3, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "" + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 1, 5, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 5, 1, 5, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 5, 5, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "left" : { + "kind" : "Identifier", + "location" : [ 5, 5, 5, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 6, 1, 6, 8 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 6, 1, 6, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 6, 5, 6, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "list" : { + "kind" : "Identifier", + "location" : [ 6, 5, 6, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 6, 7, 6, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 7, 1, 7, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 7, 1, 7, 1 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "x" + }, { + "kind" : "Identifier", + "location" : [ 7, 5, 7, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "y" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "name" : "z" + } + } ], + "errors" : { + "errors" : [ ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/student_contributed/bad_semantic.py b/src/test/data/pa2/student_contributed/bad_semantic.py new file mode 100644 index 0000000..a7a1b23 --- /dev/null +++ b/src/test/data/pa2/student_contributed/bad_semantic.py @@ -0,0 +1,4 @@ +x:int = 1 +x:int = 2 + +x diff --git a/src/test/data/pa2/student_contributed/bad_types.py b/src/test/data/pa2/student_contributed/bad_types.py new file mode 100644 index 0000000..7d76df7 --- /dev/null +++ b/src/test/data/pa2/student_contributed/bad_types.py @@ -0,0 +1,2 @@ +x:int = True +x + [1] diff --git a/src/test/data/pa2/student_contributed/good.py b/src/test/data/pa2/student_contributed/good.py new file mode 100644 index 0000000..a036d62 --- /dev/null +++ b/src/test/data/pa2/student_contributed/good.py @@ -0,0 +1,2 @@ +x:int = 1 +x * 1