You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ChocoPy/pa2-tests/core/bad_func_def_return.py.ast....

174 lines
4.3 KiB

{
"kind" : "Program",
"location" : [ 1, 1, 10, 20 ],
"declarations" : [ {
"kind" : "FuncDef",
"location" : [ 1, 1, 2, 16 ],
"name" : {
"kind" : "Identifier",
"location" : [ 1, 5, 1, 7 ],
"name" : "foo"
},
"params" : [ {
"kind" : "TypedVar",
"location" : [ 1, 9, 1, 13 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 9, 1, 9 ],
"name" : "x"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 11, 1, 13 ],
"className" : "str"
}
}, {
"kind" : "TypedVar",
"location" : [ 1, 16, 1, 21 ],
"identifier" : {
"kind" : "Identifier",
"location" : [ 1, 16, 1, 16 ],
"name" : "y"
},
"type" : {
"kind" : "ClassType",
"location" : [ 1, 18, 1, 21 ],
"className" : "bool"
}
} ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 1, 27, 1, 29 ],
"className" : "int"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 2, 5, 2, 15 ],
"errorMsg" : "Expected type `int`; got type `<None>`",
"value" : {
"kind" : "NoneLiteral",
"location" : [ 2, 12, 2, 15 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "<None>"
}
}
} ]
}, {
"kind" : "FuncDef",
"location" : [ 4, 1, 5, 13 ],
"name" : {
"kind" : "Identifier",
"location" : [ 4, 5, 4, 7 ],
"name" : "bar"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 4, 14, 4, 17 ],
"className" : "bool"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 5, 5, 5, 12 ],
"errorMsg" : "Expected type `bool`; got type `int`",
"value" : {
"kind" : "IntegerLiteral",
"location" : [ 5, 12, 5, 12 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"value" : 1
}
} ]
}, {
"kind" : "FuncDef",
"location" : [ 7, 1, 8, 11 ],
"name" : {
"kind" : "Identifier",
"location" : [ 7, 5, 7, 7 ],
"name" : "baz"
},
"params" : [ ],
"returnType" : {
"kind" : "ClassType",
"location" : [ 7, 14, 7, 16 ],
"className" : "str"
},
"declarations" : [ ],
"statements" : [ {
"kind" : "ReturnStmt",
"location" : [ 8, 5, 8, 10 ],
"errorMsg" : "Expected type `str`; got `None`",
"value" : null
} ]
} ],
"statements" : [ {
"kind" : "ExprStmt",
"location" : [ 10, 1, 10, 19 ],
"expr" : {
"kind" : "CallExpr",
"location" : [ 10, 1, 10, 19 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "int"
},
"function" : {
"kind" : "Identifier",
"location" : [ 10, 1, 10, 3 ],
"inferredType" : {
"kind" : "FuncType",
"parameters" : [ {
"kind" : "ClassValueType",
"className" : "str"
}, {
"kind" : "ClassValueType",
"className" : "bool"
} ],
"returnType" : {
"kind" : "ClassValueType",
"className" : "int"
}
},
"name" : "foo"
},
"args" : [ {
"kind" : "StringLiteral",
"location" : [ 10, 5, 10, 11 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "str"
},
"value" : "Hello"
}, {
"kind" : "BooleanLiteral",
"location" : [ 10, 14, 10, 18 ],
"inferredType" : {
"kind" : "ClassValueType",
"className" : "bool"
},
"value" : false
} ]
}
} ],
"errors" : {
"errors" : [ {
"kind" : "CompilerError",
"location" : [ 2, 5, 2, 15 ],
"message" : "Expected type `int`; got type `<None>`"
}, {
"kind" : "CompilerError",
"location" : [ 5, 5, 5, 12 ],
"message" : "Expected type `bool`; got type `int`"
}, {
"kind" : "CompilerError",
"location" : [ 8, 5, 8, 10 ],
"message" : "Expected type `str`; got `None`"
} ],
"kind" : "Errors",
"location" : [ 0, 0, 0, 0 ]
}
}