From ffba0838d7d90b161cfbdc458a956a60f21db6ea Mon Sep 17 00:00:00 2001 From: Sanjar Ahmadov Date: Sun, 4 Apr 2021 12:16:13 +0400 Subject: [PATCH] Updated good.py and added other ast.typed files --- .../bad_semantic.py.ast.typed | 1053 +++++++++++++ .../bad_types.py.ast.typed | 1307 +++++++++++++++++ src/test/data/pa2/student_contributed/good.py | 7 +- .../pa2/student_contributed/good.py.ast.typed | 1230 ++++++++++++---- 4 files changed, 3289 insertions(+), 308 deletions(-) create mode 100644 src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed create mode 100644 src/test/data/pa2/student_contributed/bad_types.py.ast.typed diff --git a/src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed b/src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed new file mode 100644 index 0000000..bd84531 --- /dev/null +++ b/src/test/data/pa2/student_contributed/bad_semantic.py.ast.typed @@ -0,0 +1,1053 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 92, 11 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 10, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 13 ], + "name" : "A_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 15, 2, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 13 ], + "name" : "a_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 15, 3, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 21, 3, 21 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 18 ], + "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, 31 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 31 ], + "className" : "A_CLASS" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 34, 4, 38 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 34, 4, 34 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 36, 4, 38 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 40, 4, 40 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 9, 5, 18 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 5, 9, 5, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 14, 5, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 18 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 8, 5, 10, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 11 ], + "errorMsg" : "First parameter of the following method must be of the enclosing class: add", + "name" : "add" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 8, 13, 8, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 13 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 8, 15, 8, 17 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 8, 23, 8, 25 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 9, 9, 9, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 9, 9, 9, 9 ], + "name" : "y" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 9, 13, 9, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 9, 13, 9, 13 ], + "name" : "y" + }, + "operator" : "+", + "right" : { + "kind" : "MemberExpr", + "location" : [ 9, 15, 9, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 9, 15, 9, 18 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 9, 20, 9, 20 ], + "name" : "x" + } + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 10, 9, 10, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 10, 16, 10, 16 ], + "name" : "y" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 12, 1, 13, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 12, 7, 12, 13 ], + "name" : "B_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 12, 15, 12, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 13, 5, 13, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 13, 5, 13, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 13, 5, 13, 13 ], + "name" : "b_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 13, 15, 13, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 13, 21, 13, 21 ], + "value" : 0 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 15, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 15, 7, 15, 13 ], + "name" : "C_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 15, 15, 15, 21 ], + "name" : "B_CLASS" + }, + "declarations" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 19, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 19, 7, 19, 13 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: A_CLASS", + "name" : "A_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 19, 15, 19, 20 ], + "name" : "object" + }, + "declarations" : [ ] + }, { + "kind" : "ClassDef", + "location" : [ 23, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 23, 7, 23, 13 ], + "name" : "D_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 23, 15, 23, 21 ], + "errorMsg" : "Super-class not defined: E_CLASS", + "name" : "E_CLASS" + }, + "declarations" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 28, 1, 28, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 28, 1, 28, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 3 ], + "name" : "a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 28, 5, 28, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 28, 11, 28, 15 ], + "value" : "a_s" + } + }, { + "kind" : "VarDef", + "location" : [ 29, 1, 29, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 29, 1, 29, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 29, 1, 29, 3 ], + "name" : "b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 29, 5, 29, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 29, 11, 29, 15 ], + "value" : "b_s" + } + }, { + "kind" : "VarDef", + "location" : [ 30, 1, 30, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 30, 1, 30, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 30, 1, 30, 3 ], + "name" : "c_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 30, 5, 30, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 30, 11, 30, 15 ], + "value" : "c_s" + } + }, { + "kind" : "VarDef", + "location" : [ 32, 1, 32, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 32, 1, 32, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 3 ], + "name" : "a_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 32, 5, 32, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 32, 11, 32, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 33, 1, 33, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 33, 1, 33, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 33, 1, 33, 3 ], + "name" : "b_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 33, 5, 33, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 33, 11, 33, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 34, 1, 34, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 34, 1, 34, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 34, 1, 34, 3 ], + "name" : "c_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 34, 5, 34, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 34, 11, 34, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 36, 1, 36, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 36, 1, 36, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 3 ], + "name" : "a_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 36, 5, 36, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 36, 12, 36, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 37, 1, 37, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 37, 1, 37, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 37, 1, 37, 3 ], + "name" : "b_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 37, 5, 37, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 37, 12, 37, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 38, 1, 38, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 38, 1, 38, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 38, 1, 38, 3 ], + "name" : "c_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 38, 5, 38, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 38, 12, 38, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 40, 1, 40, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 40, 1, 40, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 40, 1, 40, 6 ], + "name" : "a_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 40, 8, 40, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 40, 9, 40, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 40, 16, 40, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 41, 1, 41, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 41, 1, 41, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 41, 1, 41, 6 ], + "name" : "b_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 41, 8, 41, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 41, 9, 41, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 41, 16, 41, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 42, 1, 42, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 42, 1, 42, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 42, 1, 42, 6 ], + "name" : "c_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 42, 8, 42, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 42, 9, 42, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 42, 16, 42, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 44, 1, 44, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 44, 1, 44, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 44, 1, 44, 7 ], + "name" : "a_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 44, 9, 44, 15 ], + "className" : "A_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 44, 19, 44, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 45, 1, 45, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 45, 1, 45, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 45, 1, 45, 7 ], + "name" : "b_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 45, 9, 45, 15 ], + "className" : "B_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 45, 19, 45, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 46, 1, 46, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 46, 1, 46, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 46, 1, 46, 7 ], + "name" : "c_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 46, 9, 46, 15 ], + "className" : "C_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 46, 19, 46, 22 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 50, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 50, 5, 50, 7 ], + "name" : "f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 50, 14, 50, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 51, 5, 54, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 51, 9, 51, 13 ], + "name" : "f_f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 51, 20, 51, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 53, 9, 53, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 53, 16, 53, 18 ], + "name" : "a_s" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 54, 9, 54, 18 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 54, 9, 54, 18 ], + "function" : { + "kind" : "Identifier", + "location" : [ 54, 9, 54, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 54, 15, 54, 17 ], + "name" : "a_s" + } ] + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 58, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 58, 5, 58, 7 ], + "name" : "f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 58, 14, 58, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 59, 5, 59, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 59, 5, 59, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 59, 5, 59, 9 ], + "name" : "f_a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 59, 11, 59, 13 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 59, 17, 59, 19 ], + "value" : "s" + } + }, { + "kind" : "FuncDef", + "location" : [ 60, 5, 62, 20 ], + "name" : { + "kind" : "Identifier", + "location" : [ 60, 9, 60, 13 ], + "name" : "f_f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 60, 20, 60, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 61, 9, 61, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 61, 18, 61, 22 ], + "name" : "f_a_s" + } + } ], + "statements" : [ { + "kind" : "ExprStmt", + "location" : [ 62, 9, 62, 20 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 62, 9, 62, 20 ], + "function" : { + "kind" : "Identifier", + "location" : [ 62, 9, 62, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 62, 15, 62, 19 ], + "name" : "f_a_s" + } ] + } + } ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 66, 1, 72, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 66, 5, 66, 7 ], + "name" : "f_3" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 66, 9, 66, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 66, 9, 66, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 66, 11, 66, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 66, 19, 66, 22 ], + "className" : "bool" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 67, 5, 67, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 67, 5, 67, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 67, 5, 67, 9 ], + "name" : "f_b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 67, 11, 67, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 67, 17, 67, 17 ], + "value" : 3 + } + } ], + "statements" : [ { + "kind" : "IfStmt", + "location" : [ 68, 5, 0, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 68, 9, 68, 21 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 68, 9, 68, 17 ], + "left" : { + "kind" : "Identifier", + "location" : [ 68, 9, 68, 9 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 68, 13, 68, 17 ], + "name" : "f_b_s" + } + }, + "operator" : ">", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 68, 21, 68, 21 ], + "value" : 3 + } + }, + "thenBody" : [ { + "kind" : "ReturnStmt", + "location" : [ 69, 9, 69, 19 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 69, 16, 69, 19 ], + "value" : true + } + } ], + "elseBody" : [ { + "kind" : "IfStmt", + "location" : [ 70, 5, 0, 0 ], + "condition" : { + "kind" : "BinaryExpr", + "location" : [ 70, 11, 70, 24 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 70, 11, 70, 19 ], + "left" : { + "kind" : "Identifier", + "location" : [ 70, 11, 70, 11 ], + "name" : "x" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 70, 15, 70, 19 ], + "name" : "f_b_s" + } + }, + "operator" : "==", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 70, 24, 70, 24 ], + "value" : 3 + } + }, + "thenBody" : [ { + "kind" : "ExprStmt", + "location" : [ 71, 9, 71, 22 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 71, 9, 71, 22 ], + "function" : { + "kind" : "Identifier", + "location" : [ 71, 9, 71, 13 ], + "name" : "print" + }, + "args" : [ { + "kind" : "StringLiteral", + "location" : [ 71, 15, 71, 21 ], + "value" : "Equal" + } ] + } + } ], + "elseBody" : [ ] + } ] + }, { + "kind" : "ReturnStmt", + "location" : [ 72, 5, 72, 16 ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 72, 12, 72, 16 ], + "value" : false + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 74, 1, 77, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 74, 5, 74, 7 ], + "name" : "f_4" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 74, 14, 74, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 75, 5, 75, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 75, 5, 75, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 75, 5, 75, 9 ], + "name" : "f_a_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 75, 11, 75, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 75, 17, 75, 17 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 76, 5, 76, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 76, 5, 76, 7 ], + "name" : "a_i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 76, 11, 76, 19 ], + "left" : { + "kind" : "Identifier", + "location" : [ 76, 11, 76, 15 ], + "name" : "f_a_i" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 76, 19, 76, 19 ], + "value" : 1 + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 77, 5, 77, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 77, 12, 77, 16 ], + "name" : "f_a_i" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 81, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 81, 5, 81, 7 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: f_2", + "name" : "f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 81, 14, 81, 19 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 85, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 85, 5, 85, 9 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: print", + "name" : "print" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 85, 11, 85, 20 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 85, 11, 85, 13 ], + "name" : "val" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 85, 15, 85, 20 ], + "className" : "object" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 85, 26, 85, 31 ], + "className" : "object" + }, + "declarations" : [ ], + "statements" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 89, 1, 89, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 89, 1, 89, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 89, 1, 89, 3 ], + "errorMsg" : "Duplicate declaration of identifier in same scope: a_i", + "name" : "a_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 89, 5, 89, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 89, 11, 89, 11 ], + "value" : 2 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 92, 1, 92, 10 ], + "value" : { + "kind" : "Identifier", + "location" : [ 92, 8, 92, 10 ], + "name" : "a_i" + } + } ], + "errors" : { + "errors" : [ { + "kind" : "CompilerError", + "location" : [ 19, 7, 19, 13 ], + "message" : "Duplicate declaration of identifier in same scope: A_CLASS" + }, { + "kind" : "CompilerError", + "location" : [ 23, 15, 23, 21 ], + "message" : "Super-class not defined: E_CLASS" + }, { + "kind" : "CompilerError", + "location" : [ 81, 5, 81, 7 ], + "message" : "Duplicate declaration of identifier in same scope: f_2" + }, { + "kind" : "CompilerError", + "location" : [ 85, 5, 85, 9 ], + "message" : "Duplicate declaration of identifier in same scope: print" + }, { + "kind" : "CompilerError", + "location" : [ 89, 1, 89, 3 ], + "message" : "Duplicate declaration of identifier in same scope: a_i" + }, { + "kind" : "CompilerError", + "location" : [ 4, 9, 4, 16 ], + "message" : "Method overridden with different type signature: __init__" + }, { + "kind" : "CompilerError", + "location" : [ 8, 9, 8, 11 ], + "message" : "First parameter of the following method must be of the enclosing class: add" + } ], + "kind" : "Errors", + "location" : [ 0, 0, 0, 0 ] + } +} \ No newline at end of file diff --git a/src/test/data/pa2/student_contributed/bad_types.py.ast.typed b/src/test/data/pa2/student_contributed/bad_types.py.ast.typed new file mode 100644 index 0000000..b5c130f --- /dev/null +++ b/src/test/data/pa2/student_contributed/bad_types.py.ast.typed @@ -0,0 +1,1307 @@ +{ + "kind" : "Program", + "location" : [ 2, 1, 105, 70 ], + "declarations" : [ { + "kind" : "ClassDef", + "location" : [ 2, 1, 9, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 2, 7, 2, 13 ], + "name" : "A_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 2, 15, 2, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 3, 5, 3, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 3, 5, 3, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 3, 5, 3, 13 ], + "name" : "a_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 3, 15, 3, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 3, 21, 3, 21 ], + "value" : 0 + } + }, { + "kind" : "FuncDef", + "location" : [ 4, 5, 5, 18 ], + "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, 31 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 18, 4, 21 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 23, 4, 31 ], + "className" : "A_CLASS" + } + }, { + "kind" : "TypedVar", + "location" : [ 4, 34, 4, 38 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 34, 4, 34 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 36, 4, 38 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 4, 40, 4, 40 ], + "className" : "" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 5, 9, 5, 18 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 5, 9, 5, 14 ], + "object" : { + "kind" : "Identifier", + "location" : [ 5, 9, 5, 12 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 5, 14, 5, 14 ], + "name" : "x" + } + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 5, 18, 5, 18 ], + "name" : "x" + } + } ] + }, { + "kind" : "FuncDef", + "location" : [ 7, 5, 9, 16 ], + "name" : { + "kind" : "Identifier", + "location" : [ 7, 9, 7, 11 ], + "name" : "add" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 7, 13, 7, 26 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 13, 7, 16 ], + "name" : "self" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 18, 7, 26 ], + "className" : "A_CLASS" + } + }, { + "kind" : "TypedVar", + "location" : [ 7, 29, 7, 33 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 7, 29, 7, 29 ], + "name" : "y" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 7, 31, 7, 33 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 7, 39, 7, 41 ], + "className" : "int" + }, + "declarations" : [ ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 8, 9, 8, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 8, 9, 8, 9 ], + "name" : "y" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 8, 13, 8, 20 ], + "left" : { + "kind" : "Identifier", + "location" : [ 8, 13, 8, 13 ], + "name" : "y" + }, + "operator" : "+", + "right" : { + "kind" : "MemberExpr", + "location" : [ 8, 15, 8, 20 ], + "object" : { + "kind" : "Identifier", + "location" : [ 8, 15, 8, 18 ], + "name" : "self" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 8, 20, 8, 20 ], + "name" : "x" + } + } + } + }, { + "kind" : "ReturnStmt", + "location" : [ 9, 9, 9, 16 ], + "value" : { + "kind" : "Identifier", + "location" : [ 9, 16, 9, 16 ], + "name" : "y" + } + } ] + } ] + }, { + "kind" : "ClassDef", + "location" : [ 11, 1, 12, 21 ], + "name" : { + "kind" : "Identifier", + "location" : [ 11, 7, 11, 13 ], + "name" : "B_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 11, 15, 11, 20 ], + "name" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 12, 5, 12, 21 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 12, 5, 12, 17 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 12, 5, 12, 13 ], + "name" : "b_class_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 12, 15, 12, 17 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 12, 21, 12, 21 ], + "value" : 0 + } + } ] + }, { + "kind" : "ClassDef", + "location" : [ 14, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 14, 7, 14, 13 ], + "name" : "C_CLASS" + }, + "superClass" : { + "kind" : "Identifier", + "location" : [ 14, 15, 14, 21 ], + "name" : "B_CLASS" + }, + "declarations" : [ ] + }, { + "kind" : "VarDef", + "location" : [ 18, 1, 18, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 18, 1, 18, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 18, 1, 18, 3 ], + "name" : "a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 18, 5, 18, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 18, 11, 18, 15 ], + "value" : "a_s" + } + }, { + "kind" : "VarDef", + "location" : [ 19, 1, 19, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 19, 1, 19, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 19, 1, 19, 3 ], + "name" : "b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 19, 5, 19, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 19, 11, 19, 15 ], + "value" : "b_s" + } + }, { + "kind" : "VarDef", + "location" : [ 20, 1, 20, 15 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 20, 1, 20, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 20, 1, 20, 3 ], + "name" : "c_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 20, 5, 20, 7 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 20, 11, 20, 15 ], + "value" : "c_s" + } + }, { + "kind" : "VarDef", + "location" : [ 22, 1, 22, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 22, 1, 22, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 22, 1, 22, 3 ], + "name" : "a_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 22, 5, 22, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 22, 11, 22, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 23, 1, 23, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 23, 1, 23, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 23, 1, 23, 3 ], + "name" : "b_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 23, 5, 23, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 23, 11, 23, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 24, 1, 24, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 24, 1, 24, 7 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 24, 1, 24, 3 ], + "name" : "c_i" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 24, 5, 24, 7 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 24, 11, 24, 11 ], + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 26, 1, 26, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 26, 1, 26, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 26, 1, 26, 3 ], + "name" : "a_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 26, 5, 26, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 26, 12, 26, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 27, 1, 27, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 27, 1, 27, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 27, 1, 27, 3 ], + "name" : "b_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 27, 5, 27, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 27, 12, 27, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 28, 1, 28, 16 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 28, 1, 28, 8 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 28, 1, 28, 3 ], + "name" : "c_b" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 28, 5, 28, 8 ], + "className" : "bool" + } + }, + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 28, 12, 28, 16 ], + "value" : false + } + }, { + "kind" : "VarDef", + "location" : [ 30, 1, 30, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 30, 1, 30, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 30, 1, 30, 6 ], + "name" : "a_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 30, 8, 30, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 30, 9, 30, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 30, 16, 30, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 31, 1, 31, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 31, 1, 31, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 31, 1, 31, 6 ], + "name" : "b_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 31, 8, 31, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 31, 9, 31, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 31, 16, 31, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 32, 1, 32, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 32, 1, 32, 12 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 32, 1, 32, 6 ], + "name" : "c_list" + }, + "type" : { + "kind" : "ListType", + "location" : [ 32, 8, 32, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 32, 9, 32, 11 ], + "className" : "int" + } + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 32, 16, 32, 19 ] + } + }, { + "kind" : "VarDef", + "location" : [ 34, 1, 34, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 34, 1, 34, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 34, 1, 34, 7 ], + "name" : "a_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 34, 9, 34, 15 ], + "className" : "A_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 34, 19, 34, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 35, 1, 35, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 35, 1, 35, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 35, 1, 35, 7 ], + "name" : "b_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 35, 9, 35, 15 ], + "className" : "B_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 35, 19, 35, 22 ] + } + }, { + "kind" : "VarDef", + "location" : [ 36, 1, 36, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 36, 1, 36, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 36, 1, 36, 7 ], + "name" : "c_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 36, 9, 36, 15 ], + "className" : "C_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 36, 19, 36, 22 ] + } + }, { + "kind" : "FuncDef", + "location" : [ 40, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 40, 5, 40, 7 ], + "name" : "f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 40, 14, 40, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "FuncDef", + "location" : [ 41, 5, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 41, 9, 41, 13 ], + "name" : "f_f_1" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 41, 20, 41, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "GlobalDecl", + "location" : [ 42, 9, 42, 18 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 42, 16, 42, 18 ], + "name" : "a_s" + } + } ], + "statements" : [ ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 46, 1, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 46, 5, 46, 7 ], + "name" : "f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 46, 14, 46, 19 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 47, 5, 47, 19 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 47, 5, 47, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 47, 5, 47, 9 ], + "name" : "f_a_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 47, 11, 47, 13 ], + "className" : "str" + } + }, + "value" : { + "kind" : "StringLiteral", + "location" : [ 47, 17, 47, 19 ], + "value" : "s" + } + }, { + "kind" : "FuncDef", + "location" : [ 48, 5, 0, 0 ], + "name" : { + "kind" : "Identifier", + "location" : [ 48, 9, 48, 13 ], + "name" : "f_f_2" + }, + "params" : [ ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 48, 20, 48, 25 ], + "className" : "object" + }, + "declarations" : [ { + "kind" : "NonLocalDecl", + "location" : [ 49, 9, 49, 22 ], + "variable" : { + "kind" : "Identifier", + "location" : [ 49, 18, 49, 22 ], + "name" : "f_a_s" + } + } ], + "statements" : [ ] + } ], + "statements" : [ ] + }, { + "kind" : "FuncDef", + "location" : [ 53, 1, 55, 18 ], + "name" : { + "kind" : "Identifier", + "location" : [ 53, 5, 53, 7 ], + "name" : "f_3" + }, + "params" : [ { + "kind" : "TypedVar", + "location" : [ 53, 9, 53, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 53, 9, 53, 9 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 53, 11, 53, 13 ], + "className" : "int" + } + } ], + "returnType" : { + "kind" : "ClassType", + "location" : [ 53, 19, 53, 21 ], + "className" : "str" + }, + "declarations" : [ { + "kind" : "VarDef", + "location" : [ 54, 5, 54, 17 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 54, 5, 54, 13 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 54, 5, 54, 9 ], + "name" : "f_b_s" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 54, 11, 54, 13 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 54, 17, 54, 17 ], + "value" : 3 + } + } ], + "statements" : [ { + "kind" : "ReturnStmt", + "location" : [ 55, 5, 55, 18 ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 55, 12, 55, 18 ], + "left" : { + "kind" : "Identifier", + "location" : [ 55, 12, 55, 12 ], + "name" : "x" + }, + "operator" : "*", + "right" : { + "kind" : "Identifier", + "location" : [ 55, 14, 55, 18 ], + "name" : "f_b_s" + } + } + } ] + } ], + "statements" : [ { + "kind" : "AssignStmt", + "location" : [ 59, 1, 59, 18 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 59, 1, 59, 6 ], + "name" : "a_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 59, 10, 59, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 59, 11, 59, 11 ], + "value" : 1 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 14, 59, 14 ], + "value" : 2 + }, { + "kind" : "IntegerLiteral", + "location" : [ 59, 17, 59, 17 ], + "value" : 3 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 60, 1, 60, 18 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 60, 1, 60, 6 ], + "name" : "b_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 60, 10, 60, 18 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 60, 11, 60, 11 ], + "value" : 0 + }, { + "kind" : "IntegerLiteral", + "location" : [ 60, 14, 60, 14 ], + "value" : 0 + }, { + "kind" : "IntegerLiteral", + "location" : [ 60, 17, 60, 17 ], + "value" : 0 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 61, 1, 61, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 61, 1, 61, 6 ], + "name" : "c_list" + } ], + "value" : { + "kind" : "ListExpr", + "location" : [ 61, 10, 61, 21 ], + "elements" : [ { + "kind" : "UnaryExpr", + "location" : [ 61, 11, 61, 12 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 61, 12, 61, 12 ], + "value" : 1 + } + }, { + "kind" : "UnaryExpr", + "location" : [ 61, 15, 61, 16 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 61, 16, 61, 16 ], + "value" : 2 + } + }, { + "kind" : "UnaryExpr", + "location" : [ 61, 19, 61, 20 ], + "operator" : "-", + "operand" : { + "kind" : "IntegerLiteral", + "location" : [ 61, 20, 61, 20 ], + "value" : 3 + } + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 63, 1, 63, 20 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 63, 1, 63, 7 ], + "name" : "a_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 63, 11, 63, 20 ], + "function" : { + "kind" : "Identifier", + "location" : [ 63, 11, 63, 17 ], + "name" : "A_CLASS" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 63, 19, 63, 19 ], + "value" : 5 + } ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 64, 1, 64, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 64, 1, 64, 7 ], + "name" : "b_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 64, 11, 64, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 64, 11, 64, 17 ], + "name" : "B_CLASS" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 65, 1, 65, 19 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 65, 1, 65, 7 ], + "name" : "c_class" + } ], + "value" : { + "kind" : "CallExpr", + "location" : [ 65, 11, 65, 19 ], + "function" : { + "kind" : "Identifier", + "location" : [ 65, 11, 65, 17 ], + "name" : "C_CLASS" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 69, 1, 69, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 69, 1, 69, 3 ], + "name" : "c_i" + } ], + "value" : { + "kind" : "BooleanLiteral", + "location" : [ 69, 7, 69, 10 ], + "value" : true + } + }, { + "kind" : "ExprStmt", + "location" : [ 71, 1, 71, 9 ], + "expr" : { + "kind" : "BinaryExpr", + "location" : [ 71, 1, 71, 9 ], + "left" : { + "kind" : "Identifier", + "location" : [ 71, 1, 71, 3 ], + "name" : "c_i" + }, + "operator" : "+", + "right" : { + "kind" : "ListExpr", + "location" : [ 71, 7, 71, 9 ], + "elements" : [ { + "kind" : "IntegerLiteral", + "location" : [ 71, 8, 71, 8 ], + "value" : 1 + } ] + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 73, 1, 73, 23 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 73, 1, 73, 3 ], + "name" : "a_i" + }, { + "kind" : "Identifier", + "location" : [ 73, 7, 73, 9 ], + "name" : "a_b" + }, { + "kind" : "Identifier", + "location" : [ 73, 13, 73, 13 ], + "name" : "z" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 73, 17, 73, 23 ], + "value" : "Error" + } + }, { + "kind" : "AssignStmt", + "location" : [ 75, 1, 75, 13 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 75, 1, 75, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 75, 7, 75, 13 ], + "left" : { + "kind" : "Identifier", + "location" : [ 75, 7, 75, 9 ], + "name" : "a_s" + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 75, 13, 75, 13 ], + "value" : 1 + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 77, 1, 77, 14 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 77, 1, 77, 3 ], + "name" : "c_s" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 77, 7, 77, 14 ], + "list" : { + "kind" : "Identifier", + "location" : [ 77, 7, 77, 9 ], + "name" : "a_s" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 77, 11, 77, 13 ], + "name" : "a_s" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 79, 1, 79, 21 ], + "targets" : [ { + "kind" : "MemberExpr", + "location" : [ 79, 1, 79, 17 ], + "object" : { + "kind" : "Identifier", + "location" : [ 79, 1, 79, 7 ], + "name" : "b_class" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 79, 9, 79, 17 ], + "name" : "b_class_i" + } + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 79, 21, 79, 21 ], + "value" : 2 + } + }, { + "kind" : "AssignStmt", + "location" : [ 81, 1, 81, 7 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 81, 1, 81, 3 ], + "name" : "f_1" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 81, 7, 81, 7 ], + "value" : 5 + } + }, { + "kind" : "AssignStmt", + "location" : [ 83, 1, 83, 9 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 83, 1, 83, 3 ], + "name" : "f_2" + } ], + "value" : { + "kind" : "Identifier", + "location" : [ 83, 7, 83, 9 ], + "name" : "f_1" + } + }, { + "kind" : "AssignStmt", + "location" : [ 85, 1, 85, 31 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 85, 1, 85, 3 ], + "name" : "a_i" + }, { + "kind" : "MemberExpr", + "location" : [ 85, 7, 85, 23 ], + "object" : { + "kind" : "Identifier", + "location" : [ 85, 7, 85, 13 ], + "name" : "b_class" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 85, 15, 85, 23 ], + "name" : "b_class_i" + } + }, { + "kind" : "Identifier", + "location" : [ 85, 27, 85, 27 ], + "name" : "z" + } ], + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 85, 31, 85, 31 ], + "value" : 5 + } + }, { + "kind" : "AssignStmt", + "location" : [ 87, 1, 87, 10 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 87, 1, 87, 3 ], + "name" : "x_i" + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 87, 7, 87, 10 ], + "value" : "ss" + } + }, { + "kind" : "AssignStmt", + "location" : [ 89, 1, 89, 15 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 89, 1, 89, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 89, 7, 89, 15 ], + "left" : { + "kind" : "Identifier", + "location" : [ 89, 7, 89, 9 ], + "name" : "a_i" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 89, 13, 89, 15 ], + "name" : "b_i" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 91, 1, 91, 25 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 91, 1, 91, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 91, 7, 91, 25 ], + "left" : { + "kind" : "BinaryExpr", + "location" : [ 91, 7, 91, 16 ], + "left" : { + "kind" : "Identifier", + "location" : [ 91, 7, 91, 9 ], + "name" : "a_i" + }, + "operator" : "==", + "right" : { + "kind" : "Identifier", + "location" : [ 91, 14, 91, 16 ], + "name" : "b_i" + } + }, + "operator" : "and", + "right" : { + "kind" : "BooleanLiteral", + "location" : [ 91, 22, 91, 25 ], + "value" : true + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 93, 1, 93, 21 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 93, 1, 93, 6 ], + "name" : "a_list" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 93, 10, 93, 21 ], + "left" : { + "kind" : "Identifier", + "location" : [ 93, 10, 93, 15 ], + "name" : "a_list" + }, + "operator" : "+", + "right" : { + "kind" : "Identifier", + "location" : [ 93, 19, 93, 21 ], + "name" : "a_s" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 95, 1, 95, 17 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 95, 1, 95, 3 ], + "name" : "a_s" + } ], + "value" : { + "kind" : "IndexExpr", + "location" : [ 95, 7, 95, 17 ], + "list" : { + "kind" : "Identifier", + "location" : [ 95, 7, 95, 12 ], + "name" : "a_list" + }, + "index" : { + "kind" : "Identifier", + "location" : [ 95, 14, 95, 16 ], + "name" : "a_s" + } + } + }, { + "kind" : "AssignStmt", + "location" : [ 97, 1, 97, 15 ], + "targets" : [ { + "kind" : "IndexExpr", + "location" : [ 97, 1, 97, 9 ], + "list" : { + "kind" : "Identifier", + "location" : [ 97, 1, 97, 6 ], + "name" : "a_list" + }, + "index" : { + "kind" : "IntegerLiteral", + "location" : [ 97, 8, 97, 8 ], + "value" : 1 + } + } ], + "value" : { + "kind" : "StringLiteral", + "location" : [ 97, 13, 97, 15 ], + "value" : "a" + } + }, { + "kind" : "AssignStmt", + "location" : [ 99, 1, 99, 16 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 99, 1, 99, 3 ], + "name" : "a_i" + } ], + "value" : { + "kind" : "BinaryExpr", + "location" : [ 99, 7, 99, 16 ], + "left" : { + "kind" : "CallExpr", + "location" : [ 99, 7, 99, 12 ], + "function" : { + "kind" : "Identifier", + "location" : [ 99, 7, 99, 9 ], + "name" : "f_3" + }, + "args" : [ { + "kind" : "IntegerLiteral", + "location" : [ 99, 11, 99, 11 ], + "value" : 3 + } ] + }, + "operator" : "+", + "right" : { + "kind" : "IntegerLiteral", + "location" : [ 99, 16, 99, 16 ], + "value" : 5 + } + } + }, { + "kind" : "ExprStmt", + "location" : [ 101, 1, 101, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 101, 1, 101, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 101, 1, 101, 3 ], + "name" : "f_1" + }, + "args" : [ ] + } + }, { + "kind" : "ExprStmt", + "location" : [ 103, 1, 103, 5 ], + "expr" : { + "kind" : "CallExpr", + "location" : [ 103, 1, 103, 5 ], + "function" : { + "kind" : "Identifier", + "location" : [ 103, 1, 103, 3 ], + "name" : "f_2" + }, + "args" : [ ] + } + }, { + "kind" : "AssignStmt", + "location" : [ 105, 1, 105, 22 ], + "targets" : [ { + "kind" : "Identifier", + "location" : [ 105, 1, 105, 3 ], + "name" : "a_i" + } ], + "value" : { + "kind" : "MethodCallExpr", + "location" : [ 105, 7, 105, 22 ], + "method" : { + "kind" : "MemberExpr", + "location" : [ 105, 7, 105, 17 ], + "object" : { + "kind" : "Identifier", + "location" : [ 105, 7, 105, 13 ], + "name" : "a_class" + }, + "member" : { + "kind" : "Identifier", + "location" : [ 105, 15, 105, 17 ], + "name" : "add" + } + }, + "args" : [ { + "kind" : "Identifier", + "location" : [ 105, 19, 105, 21 ], + "name" : "a_s" + } ] + } + } ], + "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/student_contributed/good.py b/src/test/data/pa2/student_contributed/good.py index 825c9fb..f6ae4b9 100644 --- a/src/test/data/pa2/student_contributed/good.py +++ b/src/test/data/pa2/student_contributed/good.py @@ -1,8 +1,9 @@ # class defs class A_CLASS(object): a_class_i:int = 0 - def __init__(self:"A_CLASS", x:int): - self.x = x + x:int=0 + def __init__(self:"A_CLASS"): + self.x = 0 def add(self:"A_CLASS", y:int) -> int: y = y+self.x @@ -61,7 +62,7 @@ a_list = [1, 2, 3] b_list = [0, 0, 0] c_list = [-1, -2, -3] -a_class = A_CLASS(5) +a_class = A_CLASS() b_class = B_CLASS() c_class = C_CLASS() diff --git a/src/test/data/pa2/student_contributed/good.py.ast.typed b/src/test/data/pa2/student_contributed/good.py.ast.typed index 10b9365..f6a2fc6 100644 --- a/src/test/data/pa2/student_contributed/good.py.ast.typed +++ b/src/test/data/pa2/student_contributed/good.py.ast.typed @@ -1,9 +1,9 @@ { "kind" : "Program", - "location" : [ 2, 1, 109, 11 ], + "location" : [ 2, 1, 110, 11 ], "declarations" : [ { "kind" : "ClassDef", - "location" : [ 2, 1, 9, 16 ], + "location" : [ 2, 1, 10, 16 ], "name" : { "kind" : "Identifier", "location" : [ 2, 7, 2, 13 ], @@ -34,228 +34,262 @@ "value" : { "kind" : "IntegerLiteral", "location" : [ 3, 21, 3, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 + } + }, { + "kind" : "VarDef", + "location" : [ 4, 5, 4, 11 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 4, 5, 4, 9 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 4, 5, 4, 5 ], + "name" : "x" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 4, 7, 4, 9 ], + "className" : "int" + } + }, + "value" : { + "kind" : "IntegerLiteral", + "location" : [ 4, 11, 4, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 } }, { "kind" : "FuncDef", - "location" : [ 4, 5, 5, 18 ], + "location" : [ 5, 5, 6, 18 ], "name" : { "kind" : "Identifier", - "location" : [ 4, 9, 4, 16 ], - "errorMsg" : "Method overridden with different type signature: __init__", + "location" : [ 5, 9, 5, 16 ], "name" : "__init__" }, "params" : [ { "kind" : "TypedVar", - "location" : [ 4, 18, 4, 31 ], + "location" : [ 5, 18, 5, 31 ], "identifier" : { "kind" : "Identifier", - "location" : [ 4, 18, 4, 21 ], + "location" : [ 5, 18, 5, 21 ], "name" : "self" }, "type" : { "kind" : "ClassType", - "location" : [ 4, 23, 4, 31 ], + "location" : [ 5, 23, 5, 31 ], "className" : "A_CLASS" } - }, { - "kind" : "TypedVar", - "location" : [ 4, 34, 4, 38 ], - "identifier" : { - "kind" : "Identifier", - "location" : [ 4, 34, 4, 34 ], - "name" : "x" - }, - "type" : { - "kind" : "ClassType", - "location" : [ 4, 36, 4, 38 ], - "className" : "int" - } } ], "returnType" : { "kind" : "ClassType", - "location" : [ 4, 40, 4, 40 ], + "location" : [ 5, 33, 5, 33 ], "className" : "" }, "declarations" : [ ], "statements" : [ { "kind" : "AssignStmt", - "location" : [ 5, 9, 5, 18 ], + "location" : [ 6, 9, 6, 18 ], "targets" : [ { "kind" : "MemberExpr", - "location" : [ 5, 9, 5, 14 ], + "location" : [ 6, 9, 6, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "object" : { "kind" : "Identifier", - "location" : [ 5, 9, 5, 12 ], + "location" : [ 6, 9, 6, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, "name" : "self" }, "member" : { "kind" : "Identifier", - "location" : [ 5, 14, 5, 14 ], + "location" : [ 6, 14, 6, 14 ], "name" : "x" } } ], "value" : { - "kind" : "Identifier", - "location" : [ 5, 18, 5, 18 ], - "name" : "x" + "kind" : "IntegerLiteral", + "location" : [ 6, 18, 6, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 } } ] }, { "kind" : "FuncDef", - "location" : [ 7, 5, 9, 16 ], + "location" : [ 8, 5, 10, 16 ], "name" : { "kind" : "Identifier", - "location" : [ 7, 9, 7, 11 ], + "location" : [ 8, 9, 8, 11 ], "name" : "add" }, "params" : [ { "kind" : "TypedVar", - "location" : [ 7, 13, 7, 26 ], + "location" : [ 8, 13, 8, 26 ], "identifier" : { "kind" : "Identifier", - "location" : [ 7, 13, 7, 16 ], + "location" : [ 8, 13, 8, 16 ], "name" : "self" }, "type" : { "kind" : "ClassType", - "location" : [ 7, 18, 7, 26 ], + "location" : [ 8, 18, 8, 26 ], "className" : "A_CLASS" } }, { "kind" : "TypedVar", - "location" : [ 7, 29, 7, 33 ], + "location" : [ 8, 29, 8, 33 ], "identifier" : { "kind" : "Identifier", - "location" : [ 7, 29, 7, 29 ], + "location" : [ 8, 29, 8, 29 ], "name" : "y" }, "type" : { "kind" : "ClassType", - "location" : [ 7, 31, 7, 33 ], + "location" : [ 8, 31, 8, 33 ], "className" : "int" } } ], "returnType" : { "kind" : "ClassType", - "location" : [ 7, 39, 7, 41 ], + "location" : [ 8, 39, 8, 41 ], "className" : "int" }, "declarations" : [ ], "statements" : [ { "kind" : "AssignStmt", - "location" : [ 8, 9, 8, 20 ], + "location" : [ 9, 9, 9, 20 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 8, 9, 8, 9 ], + "location" : [ 9, 9, 9, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "y" } ], "value" : { "kind" : "BinaryExpr", - "location" : [ 8, 13, 8, 20 ], + "location" : [ 9, 13, 9, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "left" : { "kind" : "Identifier", - "location" : [ 8, 13, 8, 13 ], + "location" : [ 9, 13, 9, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "y" }, "operator" : "+", "right" : { "kind" : "MemberExpr", - "location" : [ 8, 15, 8, 20 ], + "location" : [ 9, 15, 9, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "object" : { "kind" : "Identifier", - "location" : [ 8, 15, 8, 18 ], + "location" : [ 9, 15, 9, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, "name" : "self" }, "member" : { "kind" : "Identifier", - "location" : [ 8, 20, 8, 20 ], + "location" : [ 9, 20, 9, 20 ], "name" : "x" } } } }, { "kind" : "ReturnStmt", - "location" : [ 9, 9, 9, 16 ], + "location" : [ 10, 9, 10, 16 ], "value" : { "kind" : "Identifier", - "location" : [ 9, 16, 9, 16 ], + "location" : [ 10, 16, 10, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "y" } } ] } ] }, { "kind" : "ClassDef", - "location" : [ 11, 1, 12, 21 ], + "location" : [ 12, 1, 13, 21 ], "name" : { "kind" : "Identifier", - "location" : [ 11, 7, 11, 13 ], + "location" : [ 12, 7, 12, 13 ], "name" : "B_CLASS" }, "superClass" : { "kind" : "Identifier", - "location" : [ 11, 15, 11, 20 ], + "location" : [ 12, 15, 12, 20 ], "name" : "object" }, "declarations" : [ { "kind" : "VarDef", - "location" : [ 12, 5, 12, 21 ], + "location" : [ 13, 5, 13, 21 ], "var" : { "kind" : "TypedVar", - "location" : [ 12, 5, 12, 17 ], + "location" : [ 13, 5, 13, 17 ], "identifier" : { "kind" : "Identifier", - "location" : [ 12, 5, 12, 13 ], + "location" : [ 13, 5, 13, 13 ], "name" : "b_class_i" }, "type" : { "kind" : "ClassType", - "location" : [ 12, 15, 12, 17 ], + "location" : [ 13, 15, 13, 17 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", - "location" : [ 12, 21, 12, 21 ], + "location" : [ 13, 21, 13, 21 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 } } ] }, { "kind" : "ClassDef", - "location" : [ 14, 1, 0, 0 ], + "location" : [ 15, 1, 0, 0 ], "name" : { "kind" : "Identifier", - "location" : [ 14, 7, 14, 13 ], + "location" : [ 15, 7, 15, 13 ], "name" : "C_CLASS" }, "superClass" : { "kind" : "Identifier", - "location" : [ 14, 15, 14, 21 ], + "location" : [ 15, 15, 15, 21 ], "name" : "B_CLASS" }, "declarations" : [ ] - }, { - "kind" : "VarDef", - "location" : [ 18, 1, 18, 15 ], - "var" : { - "kind" : "TypedVar", - "location" : [ 18, 1, 18, 7 ], - "identifier" : { - "kind" : "Identifier", - "location" : [ 18, 1, 18, 3 ], - "name" : "a_s" - }, - "type" : { - "kind" : "ClassType", - "location" : [ 18, 5, 18, 7 ], - "className" : "str" - } - }, - "value" : { - "kind" : "StringLiteral", - "location" : [ 18, 11, 18, 15 ], - "value" : "a_s" - } }, { "kind" : "VarDef", "location" : [ 19, 1, 19, 15 ], @@ -265,7 +299,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 19, 1, 19, 3 ], - "name" : "b_s" + "name" : "a_s" }, "type" : { "kind" : "ClassType", @@ -276,7 +310,11 @@ "value" : { "kind" : "StringLiteral", "location" : [ 19, 11, 19, 15 ], - "value" : "b_s" + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "a_s" } }, { "kind" : "VarDef", @@ -287,7 +325,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 20, 1, 20, 3 ], - "name" : "c_s" + "name" : "b_s" }, "type" : { "kind" : "ClassType", @@ -298,29 +336,37 @@ "value" : { "kind" : "StringLiteral", "location" : [ 20, 11, 20, 15 ], - "value" : "c_s" + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "b_s" } }, { "kind" : "VarDef", - "location" : [ 22, 1, 22, 11 ], + "location" : [ 21, 1, 21, 15 ], "var" : { "kind" : "TypedVar", - "location" : [ 22, 1, 22, 7 ], + "location" : [ 21, 1, 21, 7 ], "identifier" : { "kind" : "Identifier", - "location" : [ 22, 1, 22, 3 ], - "name" : "a_i" + "location" : [ 21, 1, 21, 3 ], + "name" : "c_s" }, "type" : { "kind" : "ClassType", - "location" : [ 22, 5, 22, 7 ], - "className" : "int" + "location" : [ 21, 5, 21, 7 ], + "className" : "str" } }, "value" : { - "kind" : "IntegerLiteral", - "location" : [ 22, 11, 22, 11 ], - "value" : 0 + "kind" : "StringLiteral", + "location" : [ 21, 11, 21, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, + "value" : "c_s" } }, { "kind" : "VarDef", @@ -331,7 +377,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 23, 1, 23, 3 ], - "name" : "b_i" + "name" : "a_i" }, "type" : { "kind" : "ClassType", @@ -342,6 +388,10 @@ "value" : { "kind" : "IntegerLiteral", "location" : [ 23, 11, 23, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 } }, { @@ -353,7 +403,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 24, 1, 24, 3 ], - "name" : "c_i" + "name" : "b_i" }, "type" : { "kind" : "ClassType", @@ -364,29 +414,37 @@ "value" : { "kind" : "IntegerLiteral", "location" : [ 24, 11, 24, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 } }, { "kind" : "VarDef", - "location" : [ 26, 1, 26, 16 ], + "location" : [ 25, 1, 25, 11 ], "var" : { "kind" : "TypedVar", - "location" : [ 26, 1, 26, 8 ], + "location" : [ 25, 1, 25, 7 ], "identifier" : { "kind" : "Identifier", - "location" : [ 26, 1, 26, 3 ], - "name" : "a_b" + "location" : [ 25, 1, 25, 3 ], + "name" : "c_i" }, "type" : { "kind" : "ClassType", - "location" : [ 26, 5, 26, 8 ], - "className" : "bool" + "location" : [ 25, 5, 25, 7 ], + "className" : "int" } }, "value" : { - "kind" : "BooleanLiteral", - "location" : [ 26, 12, 26, 16 ], - "value" : false + "kind" : "IntegerLiteral", + "location" : [ 25, 11, 25, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, + "value" : 0 } }, { "kind" : "VarDef", @@ -397,7 +455,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 27, 1, 27, 3 ], - "name" : "b_b" + "name" : "a_b" }, "type" : { "kind" : "ClassType", @@ -408,6 +466,10 @@ "value" : { "kind" : "BooleanLiteral", "location" : [ 27, 12, 27, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "value" : false } }, { @@ -419,7 +481,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 28, 1, 28, 3 ], - "name" : "c_b" + "name" : "b_b" }, "type" : { "kind" : "ClassType", @@ -430,32 +492,37 @@ "value" : { "kind" : "BooleanLiteral", "location" : [ 28, 12, 28, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "value" : false } }, { "kind" : "VarDef", - "location" : [ 30, 1, 30, 19 ], + "location" : [ 29, 1, 29, 16 ], "var" : { "kind" : "TypedVar", - "location" : [ 30, 1, 30, 12 ], + "location" : [ 29, 1, 29, 8 ], "identifier" : { "kind" : "Identifier", - "location" : [ 30, 1, 30, 6 ], - "name" : "a_list" + "location" : [ 29, 1, 29, 3 ], + "name" : "c_b" }, "type" : { - "kind" : "ListType", - "location" : [ 30, 8, 30, 12 ], - "elementType" : { - "kind" : "ClassType", - "location" : [ 30, 9, 30, 11 ], - "className" : "int" - } + "kind" : "ClassType", + "location" : [ 29, 5, 29, 8 ], + "className" : "bool" } }, "value" : { - "kind" : "NoneLiteral", - "location" : [ 30, 16, 30, 19 ] + "kind" : "BooleanLiteral", + "location" : [ 29, 12, 29, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, + "value" : false } }, { "kind" : "VarDef", @@ -466,7 +533,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 31, 1, 31, 6 ], - "name" : "b_list" + "name" : "a_list" }, "type" : { "kind" : "ListType", @@ -480,7 +547,11 @@ }, "value" : { "kind" : "NoneLiteral", - "location" : [ 31, 16, 31, 19 ] + "location" : [ 31, 16, 31, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } } }, { "kind" : "VarDef", @@ -491,7 +562,7 @@ "identifier" : { "kind" : "Identifier", "location" : [ 32, 1, 32, 6 ], - "name" : "c_list" + "name" : "b_list" }, "type" : { "kind" : "ListType", @@ -505,28 +576,40 @@ }, "value" : { "kind" : "NoneLiteral", - "location" : [ 32, 16, 32, 19 ] + "location" : [ 32, 16, 32, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } } }, { "kind" : "VarDef", - "location" : [ 34, 1, 34, 22 ], + "location" : [ 33, 1, 33, 19 ], "var" : { "kind" : "TypedVar", - "location" : [ 34, 1, 34, 15 ], + "location" : [ 33, 1, 33, 12 ], "identifier" : { "kind" : "Identifier", - "location" : [ 34, 1, 34, 7 ], - "name" : "a_class" + "location" : [ 33, 1, 33, 6 ], + "name" : "c_list" }, "type" : { - "kind" : "ClassType", - "location" : [ 34, 9, 34, 15 ], - "className" : "A_CLASS" + "kind" : "ListType", + "location" : [ 33, 8, 33, 12 ], + "elementType" : { + "kind" : "ClassType", + "location" : [ 33, 9, 33, 11 ], + "className" : "int" + } } }, "value" : { "kind" : "NoneLiteral", - "location" : [ 34, 19, 34, 22 ] + "location" : [ 33, 16, 33, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } } }, { "kind" : "VarDef", @@ -537,17 +620,21 @@ "identifier" : { "kind" : "Identifier", "location" : [ 35, 1, 35, 7 ], - "name" : "b_class" + "name" : "a_class" }, "type" : { "kind" : "ClassType", "location" : [ 35, 9, 35, 15 ], - "className" : "B_CLASS" + "className" : "A_CLASS" } }, "value" : { "kind" : "NoneLiteral", - "location" : [ 35, 19, 35, 22 ] + "location" : [ 35, 19, 35, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } } }, { "kind" : "VarDef", @@ -558,69 +645,117 @@ "identifier" : { "kind" : "Identifier", "location" : [ 36, 1, 36, 7 ], - "name" : "c_class" + "name" : "b_class" }, "type" : { "kind" : "ClassType", "location" : [ 36, 9, 36, 15 ], + "className" : "B_CLASS" + } + }, + "value" : { + "kind" : "NoneLiteral", + "location" : [ 36, 19, 36, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } + } + }, { + "kind" : "VarDef", + "location" : [ 37, 1, 37, 22 ], + "var" : { + "kind" : "TypedVar", + "location" : [ 37, 1, 37, 15 ], + "identifier" : { + "kind" : "Identifier", + "location" : [ 37, 1, 37, 7 ], + "name" : "c_class" + }, + "type" : { + "kind" : "ClassType", + "location" : [ 37, 9, 37, 15 ], "className" : "C_CLASS" } }, "value" : { "kind" : "NoneLiteral", - "location" : [ 36, 19, 36, 22 ] + "location" : [ 37, 19, 37, 22 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + } } }, { "kind" : "FuncDef", - "location" : [ 40, 1, 0, 0 ], + "location" : [ 41, 1, 0, 0 ], "name" : { "kind" : "Identifier", - "location" : [ 40, 5, 40, 7 ], + "location" : [ 41, 5, 41, 7 ], "name" : "f_1" }, "params" : [ ], "returnType" : { "kind" : "ClassType", - "location" : [ 40, 14, 40, 19 ], + "location" : [ 41, 14, 41, 19 ], "className" : "object" }, "declarations" : [ { "kind" : "FuncDef", - "location" : [ 41, 5, 43, 18 ], + "location" : [ 42, 5, 44, 18 ], "name" : { "kind" : "Identifier", - "location" : [ 41, 9, 41, 13 ], + "location" : [ 42, 9, 42, 13 ], "name" : "f_f_1" }, "params" : [ ], "returnType" : { "kind" : "ClassType", - "location" : [ 41, 20, 41, 25 ], + "location" : [ 42, 20, 42, 25 ], "className" : "object" }, "declarations" : [ { "kind" : "GlobalDecl", - "location" : [ 42, 9, 42, 18 ], + "location" : [ 43, 9, 43, 18 ], "variable" : { "kind" : "Identifier", - "location" : [ 42, 16, 42, 18 ], + "location" : [ 43, 16, 43, 18 ], "name" : "a_s" } } ], "statements" : [ { "kind" : "ExprStmt", - "location" : [ 43, 9, 43, 18 ], + "location" : [ 44, 9, 44, 18 ], "expr" : { "kind" : "CallExpr", - "location" : [ 43, 9, 43, 18 ], + "location" : [ 44, 9, 44, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, "function" : { "kind" : "Identifier", - "location" : [ 43, 9, 43, 13 ], + "location" : [ 44, 9, 44, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, "name" : "print" }, "args" : [ { "kind" : "Identifier", - "location" : [ 43, 15, 43, 17 ], + "location" : [ 44, 15, 44, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "a_s" } ] } @@ -629,77 +764,100 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 47, 1, 0, 0 ], + "location" : [ 48, 1, 0, 0 ], "name" : { "kind" : "Identifier", - "location" : [ 47, 5, 47, 7 ], + "location" : [ 48, 5, 48, 7 ], "name" : "f_2" }, "params" : [ ], "returnType" : { "kind" : "ClassType", - "location" : [ 47, 14, 47, 19 ], + "location" : [ 48, 14, 48, 19 ], "className" : "object" }, "declarations" : [ { "kind" : "VarDef", - "location" : [ 48, 5, 48, 19 ], + "location" : [ 49, 5, 49, 19 ], "var" : { "kind" : "TypedVar", - "location" : [ 48, 5, 48, 13 ], + "location" : [ 49, 5, 49, 13 ], "identifier" : { "kind" : "Identifier", - "location" : [ 48, 5, 48, 9 ], + "location" : [ 49, 5, 49, 9 ], "name" : "f_a_s" }, "type" : { "kind" : "ClassType", - "location" : [ 48, 11, 48, 13 ], + "location" : [ 49, 11, 49, 13 ], "className" : "str" } }, "value" : { "kind" : "StringLiteral", - "location" : [ 48, 17, 48, 19 ], + "location" : [ 49, 17, 49, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "value" : "s" } }, { "kind" : "FuncDef", - "location" : [ 49, 5, 51, 20 ], + "location" : [ 50, 5, 52, 20 ], "name" : { "kind" : "Identifier", - "location" : [ 49, 9, 49, 13 ], + "location" : [ 50, 9, 50, 13 ], "name" : "f_f_2" }, "params" : [ ], "returnType" : { "kind" : "ClassType", - "location" : [ 49, 20, 49, 25 ], + "location" : [ 50, 20, 50, 25 ], "className" : "object" }, "declarations" : [ { "kind" : "NonLocalDecl", - "location" : [ 50, 9, 50, 22 ], + "location" : [ 51, 9, 51, 22 ], "variable" : { "kind" : "Identifier", - "location" : [ 50, 18, 50, 22 ], + "location" : [ 51, 18, 51, 22 ], "name" : "f_a_s" } } ], "statements" : [ { "kind" : "ExprStmt", - "location" : [ 51, 9, 51, 20 ], + "location" : [ 52, 9, 52, 20 ], "expr" : { "kind" : "CallExpr", - "location" : [ 51, 9, 51, 20 ], + "location" : [ 52, 9, 52, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, "function" : { "kind" : "Identifier", - "location" : [ 51, 9, 51, 13 ], + "location" : [ 52, 9, 52, 13 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, "name" : "print" }, "args" : [ { "kind" : "Identifier", - "location" : [ 51, 15, 51, 19 ], + "location" : [ 52, 15, 52, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "f_a_s" } ] } @@ -708,69 +866,85 @@ "statements" : [ ] }, { "kind" : "FuncDef", - "location" : [ 55, 1, 57, 18 ], + "location" : [ 56, 1, 58, 18 ], "name" : { "kind" : "Identifier", - "location" : [ 55, 5, 55, 7 ], + "location" : [ 56, 5, 56, 7 ], "name" : "f_3" }, "params" : [ { "kind" : "TypedVar", - "location" : [ 55, 9, 55, 13 ], + "location" : [ 56, 9, 56, 13 ], "identifier" : { "kind" : "Identifier", - "location" : [ 55, 9, 55, 9 ], + "location" : [ 56, 9, 56, 9 ], "name" : "x" }, "type" : { "kind" : "ClassType", - "location" : [ 55, 11, 55, 13 ], + "location" : [ 56, 11, 56, 13 ], "className" : "int" } } ], "returnType" : { "kind" : "ClassType", - "location" : [ 55, 19, 55, 21 ], + "location" : [ 56, 19, 56, 21 ], "className" : "int" }, "declarations" : [ { "kind" : "VarDef", - "location" : [ 56, 5, 56, 17 ], + "location" : [ 57, 5, 57, 17 ], "var" : { "kind" : "TypedVar", - "location" : [ 56, 5, 56, 13 ], + "location" : [ 57, 5, 57, 13 ], "identifier" : { "kind" : "Identifier", - "location" : [ 56, 5, 56, 9 ], + "location" : [ 57, 5, 57, 9 ], "name" : "f_b_s" }, "type" : { "kind" : "ClassType", - "location" : [ 56, 11, 56, 13 ], + "location" : [ 57, 11, 57, 13 ], "className" : "int" } }, "value" : { "kind" : "IntegerLiteral", - "location" : [ 56, 17, 56, 17 ], + "location" : [ 57, 17, 57, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 3 } } ], "statements" : [ { "kind" : "ReturnStmt", - "location" : [ 57, 5, 57, 18 ], + "location" : [ 58, 5, 58, 18 ], "value" : { "kind" : "BinaryExpr", - "location" : [ 57, 12, 57, 18 ], + "location" : [ 58, 12, 58, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "left" : { "kind" : "Identifier", - "location" : [ 57, 12, 57, 12 ], + "location" : [ 58, 12, 58, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "x" }, "operator" : "*", "right" : { "kind" : "Identifier", - "location" : [ 57, 14, 57, 18 ], + "location" : [ 58, 14, 58, 18 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "f_b_s" } } @@ -778,523 +952,969 @@ } ], "statements" : [ { "kind" : "AssignStmt", - "location" : [ 60, 1, 60, 18 ], + "location" : [ 61, 1, 61, 18 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 60, 1, 60, 6 ], + "location" : [ 61, 1, 61, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "a_list" } ], "value" : { "kind" : "ListExpr", - "location" : [ 60, 10, 60, 18 ], + "location" : [ 61, 10, 61, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "elements" : [ { "kind" : "IntegerLiteral", - "location" : [ 60, 11, 60, 11 ], + "location" : [ 61, 11, 61, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 1 }, { "kind" : "IntegerLiteral", - "location" : [ 60, 14, 60, 14 ], + "location" : [ 61, 14, 61, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 2 }, { "kind" : "IntegerLiteral", - "location" : [ 60, 17, 60, 17 ], + "location" : [ 61, 17, 61, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 3 } ] } }, { "kind" : "AssignStmt", - "location" : [ 61, 1, 61, 18 ], + "location" : [ 62, 1, 62, 18 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 61, 1, 61, 6 ], + "location" : [ 62, 1, 62, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "b_list" } ], "value" : { "kind" : "ListExpr", - "location" : [ 61, 10, 61, 18 ], + "location" : [ 62, 10, 62, 18 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "elements" : [ { "kind" : "IntegerLiteral", - "location" : [ 61, 11, 61, 11 ], + "location" : [ 62, 11, 62, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 }, { "kind" : "IntegerLiteral", - "location" : [ 61, 14, 61, 14 ], + "location" : [ 62, 14, 62, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 }, { "kind" : "IntegerLiteral", - "location" : [ 61, 17, 61, 17 ], + "location" : [ 62, 17, 62, 17 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 } ] } }, { "kind" : "AssignStmt", - "location" : [ 62, 1, 62, 21 ], + "location" : [ 63, 1, 63, 21 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 62, 1, 62, 6 ], + "location" : [ 63, 1, 63, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "c_list" } ], "value" : { "kind" : "ListExpr", - "location" : [ 62, 10, 62, 21 ], + "location" : [ 63, 10, 63, 21 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "elements" : [ { "kind" : "UnaryExpr", - "location" : [ 62, 11, 62, 12 ], + "location" : [ 63, 11, 63, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "operator" : "-", "operand" : { "kind" : "IntegerLiteral", - "location" : [ 62, 12, 62, 12 ], + "location" : [ 63, 12, 63, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 1 } }, { "kind" : "UnaryExpr", - "location" : [ 62, 15, 62, 16 ], + "location" : [ 63, 15, 63, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "operator" : "-", "operand" : { "kind" : "IntegerLiteral", - "location" : [ 62, 16, 62, 16 ], + "location" : [ 63, 16, 63, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 2 } }, { "kind" : "UnaryExpr", - "location" : [ 62, 19, 62, 20 ], + "location" : [ 63, 19, 63, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "operator" : "-", "operand" : { "kind" : "IntegerLiteral", - "location" : [ 62, 20, 62, 20 ], + "location" : [ 63, 20, 63, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 3 } } ] } }, { "kind" : "AssignStmt", - "location" : [ 64, 1, 64, 20 ], + "location" : [ 65, 1, 65, 19 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 64, 1, 64, 7 ], + "location" : [ 65, 1, 65, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, "name" : "a_class" } ], "value" : { "kind" : "CallExpr", - "location" : [ 64, 11, 64, 20 ], + "location" : [ 65, 11, 65, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, "function" : { "kind" : "Identifier", - "location" : [ 64, 11, 64, 17 ], + "location" : [ 65, 11, 65, 17 ], "name" : "A_CLASS" }, - "args" : [ { - "kind" : "IntegerLiteral", - "location" : [ 64, 19, 64, 19 ], - "value" : 5 - } ] + "args" : [ ] } }, { "kind" : "AssignStmt", - "location" : [ 65, 1, 65, 19 ], + "location" : [ 66, 1, 66, 19 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 65, 1, 65, 7 ], + "location" : [ 66, 1, 66, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B_CLASS" + }, "name" : "b_class" } ], "value" : { "kind" : "CallExpr", - "location" : [ 65, 11, 65, 19 ], + "location" : [ 66, 11, 66, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "B_CLASS" + }, "function" : { "kind" : "Identifier", - "location" : [ 65, 11, 65, 17 ], + "location" : [ 66, 11, 66, 17 ], "name" : "B_CLASS" }, "args" : [ ] } }, { "kind" : "AssignStmt", - "location" : [ 66, 1, 66, 19 ], + "location" : [ 67, 1, 67, 19 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 66, 1, 66, 7 ], + "location" : [ 67, 1, 67, 7 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C_CLASS" + }, "name" : "c_class" } ], "value" : { "kind" : "CallExpr", - "location" : [ 66, 11, 66, 19 ], + "location" : [ 67, 11, 67, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C_CLASS" + }, "function" : { "kind" : "Identifier", - "location" : [ 66, 11, 66, 17 ], + "location" : [ 67, 11, 67, 17 ], "name" : "C_CLASS" }, "args" : [ ] } }, { "kind" : "AssignStmt", - "location" : [ 74, 1, 74, 15 ], + "location" : [ 75, 1, 75, 15 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 74, 1, 74, 3 ], + "location" : [ 75, 1, 75, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "a_s" } ], "value" : { "kind" : "BinaryExpr", - "location" : [ 74, 7, 74, 15 ], + "location" : [ 75, 7, 75, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "left" : { "kind" : "Identifier", - "location" : [ 74, 7, 74, 9 ], + "location" : [ 75, 7, 75, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "a_s" }, "operator" : "+", "right" : { "kind" : "Identifier", - "location" : [ 74, 13, 74, 15 ], + "location" : [ 75, 13, 75, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "b_s" } } }, { "kind" : "ExprStmt", - "location" : [ 75, 1, 75, 10 ], + "location" : [ 76, 1, 76, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 75, 1, 75, 10 ], + "location" : [ 76, 1, 76, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, "function" : { "kind" : "Identifier", - "location" : [ 75, 1, 75, 5 ], + "location" : [ 76, 1, 76, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, "name" : "print" }, "args" : [ { "kind" : "Identifier", - "location" : [ 75, 7, 75, 9 ], + "location" : [ 76, 7, 76, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "a_s" } ] } }, { "kind" : "AssignStmt", - "location" : [ 78, 1, 78, 12 ], + "location" : [ 79, 1, 79, 12 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 78, 1, 78, 3 ], + "location" : [ 79, 1, 79, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "c_s" } ], "value" : { "kind" : "IndexExpr", - "location" : [ 78, 7, 78, 12 ], + "location" : [ 79, 7, 79, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "list" : { "kind" : "Identifier", - "location" : [ 78, 7, 78, 9 ], + "location" : [ 79, 7, 79, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "a_s" }, "index" : { "kind" : "IntegerLiteral", - "location" : [ 78, 11, 78, 11 ], + "location" : [ 79, 11, 79, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 } } }, { "kind" : "ExprStmt", - "location" : [ 79, 1, 79, 10 ], + "location" : [ 80, 1, 80, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 79, 1, 79, 10 ], + "location" : [ 80, 1, 80, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, "function" : { "kind" : "Identifier", - "location" : [ 79, 1, 79, 5 ], + "location" : [ 80, 1, 80, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, "name" : "print" }, "args" : [ { "kind" : "Identifier", - "location" : [ 79, 7, 79, 9 ], + "location" : [ 80, 7, 80, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "str" + }, "name" : "c_s" } ] } }, { "kind" : "AssignStmt", - "location" : [ 84, 1, 84, 28 ], + "location" : [ 85, 1, 85, 28 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 84, 1, 84, 3 ], + "location" : [ 85, 1, 85, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "name" : "a_b" } ], "value" : { "kind" : "BinaryExpr", - "location" : [ 84, 7, 84, 28 ], + "location" : [ 85, 7, 85, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "left" : { "kind" : "BinaryExpr", - "location" : [ 84, 7, 84, 16 ], + "location" : [ 85, 7, 85, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "left" : { "kind" : "Identifier", - "location" : [ 84, 7, 84, 9 ], + "location" : [ 85, 7, 85, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "a_i" }, "operator" : "==", "right" : { "kind" : "Identifier", - "location" : [ 84, 14, 84, 16 ], + "location" : [ 85, 14, 85, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "b_i" } }, "operator" : "and", "right" : { "kind" : "UnaryExpr", - "location" : [ 84, 22, 84, 28 ], + "location" : [ 85, 22, 85, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "operator" : "not", "operand" : { "kind" : "Identifier", - "location" : [ 84, 26, 84, 28 ], + "location" : [ 85, 26, 85, 28 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "name" : "b_b" } } } }, { "kind" : "ExprStmt", - "location" : [ 85, 1, 85, 10 ], + "location" : [ 86, 1, 86, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 85, 1, 85, 10 ], + "location" : [ 86, 1, 86, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, "function" : { "kind" : "Identifier", - "location" : [ 85, 1, 85, 5 ], + "location" : [ 86, 1, 86, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, "name" : "print" }, "args" : [ { "kind" : "Identifier", - "location" : [ 85, 7, 85, 9 ], + "location" : [ 86, 7, 86, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "bool" + }, "name" : "a_b" } ] } }, { "kind" : "AssignStmt", - "location" : [ 90, 1, 90, 24 ], + "location" : [ 91, 1, 91, 24 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 90, 1, 90, 6 ], + "location" : [ 91, 1, 91, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "a_list" } ], "value" : { "kind" : "BinaryExpr", - "location" : [ 90, 10, 90, 24 ], + "location" : [ 91, 10, 91, 24 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "left" : { "kind" : "Identifier", - "location" : [ 90, 10, 90, 15 ], + "location" : [ 91, 10, 91, 15 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "a_list" }, "operator" : "+", "right" : { "kind" : "Identifier", - "location" : [ 90, 19, 90, 24 ], + "location" : [ 91, 19, 91, 24 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "b_list" } } }, { "kind" : "AssignStmt", - "location" : [ 91, 1, 91, 15 ], + "location" : [ 92, 1, 92, 15 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 91, 1, 91, 3 ], + "location" : [ 92, 1, 92, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "c_i" } ], "value" : { "kind" : "IndexExpr", - "location" : [ 91, 7, 91, 15 ], + "location" : [ 92, 7, 92, 15 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "list" : { "kind" : "Identifier", - "location" : [ 91, 7, 91, 12 ], + "location" : [ 92, 7, 92, 12 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "a_list" }, "index" : { "kind" : "IntegerLiteral", - "location" : [ 91, 14, 91, 14 ], + "location" : [ 92, 14, 92, 14 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 0 } } }, { "kind" : "AssignStmt", - "location" : [ 92, 1, 92, 13 ], + "location" : [ 93, 1, 93, 13 ], "targets" : [ { "kind" : "IndexExpr", - "location" : [ 92, 1, 92, 9 ], + "location" : [ 93, 1, 93, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "list" : { "kind" : "Identifier", - "location" : [ 92, 1, 92, 6 ], + "location" : [ 93, 1, 93, 6 ], + "inferredType" : { + "kind" : "ListValueType", + "elementType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "a_list" }, "index" : { "kind" : "IntegerLiteral", - "location" : [ 92, 8, 92, 8 ], + "location" : [ 93, 8, 93, 8 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 1 } } ], "value" : { "kind" : "IntegerLiteral", - "location" : [ 92, 13, 92, 13 ], + "location" : [ 93, 13, 93, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 2 } }, { "kind" : "AssignStmt", - "location" : [ 97, 1, 97, 16 ], + "location" : [ 98, 1, 98, 16 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 97, 1, 97, 3 ], + "location" : [ 98, 1, 98, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "a_i" } ], "value" : { "kind" : "BinaryExpr", - "location" : [ 97, 7, 97, 16 ], + "location" : [ 98, 7, 98, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "left" : { "kind" : "CallExpr", - "location" : [ 97, 7, 97, 12 ], + "location" : [ 98, 7, 98, 12 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "function" : { "kind" : "Identifier", - "location" : [ 97, 7, 97, 9 ], + "location" : [ 98, 7, 98, 9 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "name" : "f_3" }, "args" : [ { "kind" : "IntegerLiteral", - "location" : [ 97, 11, 97, 11 ], + "location" : [ 98, 11, 98, 11 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 3 } ] }, "operator" : "+", "right" : { "kind" : "IntegerLiteral", - "location" : [ 97, 16, 97, 16 ], + "location" : [ 98, 16, 98, 16 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 5 } } }, { "kind" : "ExprStmt", - "location" : [ 98, 1, 98, 5 ], + "location" : [ 99, 1, 99, 5 ], "expr" : { "kind" : "CallExpr", - "location" : [ 98, 1, 98, 5 ], + "location" : [ 99, 1, 99, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, "function" : { "kind" : "Identifier", - "location" : [ 98, 1, 98, 3 ], + "location" : [ 99, 1, 99, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, "name" : "f_1" }, "args" : [ ] } }, { "kind" : "ExprStmt", - "location" : [ 99, 1, 99, 5 ], + "location" : [ 100, 1, 100, 5 ], "expr" : { "kind" : "CallExpr", - "location" : [ 99, 1, 99, 5 ], + "location" : [ 100, 1, 100, 5 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "object" + }, "function" : { "kind" : "Identifier", - "location" : [ 99, 1, 99, 3 ], + "location" : [ 100, 1, 100, 3 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "object" + } + }, "name" : "f_2" }, "args" : [ ] } }, { "kind" : "AssignStmt", - "location" : [ 104, 1, 104, 20 ], + "location" : [ 105, 1, 105, 20 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 104, 1, 104, 3 ], + "location" : [ 105, 1, 105, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "a_i" } ], "value" : { "kind" : "MethodCallExpr", - "location" : [ 104, 7, 104, 20 ], + "location" : [ 105, 7, 105, 20 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "method" : { "kind" : "MemberExpr", - "location" : [ 104, 7, 104, 17 ], + "location" : [ 105, 7, 105, 17 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "object" : { "kind" : "Identifier", - "location" : [ 104, 7, 104, 13 ], + "location" : [ 105, 7, 105, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, "name" : "a_class" }, "member" : { "kind" : "Identifier", - "location" : [ 104, 15, 104, 17 ], + "location" : [ 105, 15, 105, 17 ], "name" : "add" } }, "args" : [ { "kind" : "IntegerLiteral", - "location" : [ 104, 19, 104, 19 ], + "location" : [ 105, 19, 105, 19 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "value" : 2 } ] } }, { "kind" : "ExprStmt", - "location" : [ 105, 1, 105, 10 ], + "location" : [ 106, 1, 106, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 105, 1, 105, 10 ], + "location" : [ 106, 1, 106, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, "function" : { "kind" : "Identifier", - "location" : [ 105, 1, 105, 5 ], + "location" : [ 106, 1, 106, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, "name" : "print" }, "args" : [ { "kind" : "Identifier", - "location" : [ 105, 7, 105, 9 ], + "location" : [ 106, 7, 106, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "a_i" } ] } }, { "kind" : "AssignStmt", - "location" : [ 108, 1, 108, 36 ], + "location" : [ 109, 1, 109, 36 ], "targets" : [ { "kind" : "Identifier", - "location" : [ 108, 1, 108, 3 ], + "location" : [ 109, 1, 109, 3 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "a_i" } ], "value" : { "kind" : "MethodCallExpr", - "location" : [ 108, 7, 108, 36 ], + "location" : [ 109, 7, 109, 36 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "method" : { "kind" : "MemberExpr", - "location" : [ 108, 7, 108, 17 ], + "location" : [ 109, 7, 109, 17 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, { + "kind" : "ClassValueType", + "className" : "int" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "int" + } + }, "object" : { "kind" : "Identifier", - "location" : [ 108, 7, 108, 13 ], + "location" : [ 109, 7, 109, 13 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "A_CLASS" + }, "name" : "a_class" }, "member" : { "kind" : "Identifier", - "location" : [ 108, 15, 108, 17 ], + "location" : [ 109, 15, 109, 17 ], "name" : "add" } }, "args" : [ { "kind" : "MemberExpr", - "location" : [ 108, 19, 108, 35 ], + "location" : [ 109, 19, 109, 35 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "object" : { "kind" : "Identifier", - "location" : [ 108, 19, 108, 25 ], + "location" : [ 109, 19, 109, 25 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "C_CLASS" + }, "name" : "c_class" }, "member" : { "kind" : "Identifier", - "location" : [ 108, 27, 108, 35 ], + "location" : [ 109, 27, 109, 35 ], "name" : "b_class_i" } } ] } }, { "kind" : "ExprStmt", - "location" : [ 109, 1, 109, 10 ], + "location" : [ 110, 1, 110, 10 ], "expr" : { "kind" : "CallExpr", - "location" : [ 109, 1, 109, 10 ], + "location" : [ 110, 1, 110, 10 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "" + }, "function" : { "kind" : "Identifier", - "location" : [ 109, 1, 109, 5 ], + "location" : [ 110, 1, 110, 5 ], + "inferredType" : { + "kind" : "FuncType", + "parameters" : [ { + "kind" : "ClassValueType", + "className" : "object" + } ], + "returnType" : { + "kind" : "ClassValueType", + "className" : "" + } + }, "name" : "print" }, "args" : [ { "kind" : "Identifier", - "location" : [ 109, 7, 109, 9 ], + "location" : [ 110, 7, 110, 9 ], + "inferredType" : { + "kind" : "ClassValueType", + "className" : "int" + }, "name" : "a_i" } ] } } ], "errors" : { - "errors" : [ { - "kind" : "CompilerError", - "location" : [ 4, 9, 4, 16 ], - "message" : "Method overridden with different type signature: __init__" - } ], + "errors" : [ ], "kind" : "Errors", "location" : [ 0, 0, 0, 0 ] }