diff --git a/integration_tests/class_06.py b/integration_tests/class_06.py index 981c75910c..8f9d71b35f 100644 --- a/integration_tests/class_06.py +++ b/integration_tests/class_06.py @@ -6,11 +6,13 @@ def __init__(self:"Base"): class Derived(Base): pass -def f(i:Base): +def f(i:Base) -> i32: print(i.x) + return i.x def main(): d : Derived = Derived() - f(d) + op :i32 = f(d) + assert op == 10 main() diff --git a/tests/reference/asr-class_06-cdc5e29.json b/tests/reference/asr-class_06-cdc5e29.json index b8577a9ed0..e22d71d362 100644 --- a/tests/reference/asr-class_06-cdc5e29.json +++ b/tests/reference/asr-class_06-cdc5e29.json @@ -2,11 +2,11 @@ "basename": "asr-class_06-cdc5e29", "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", "infile": "tests/../integration_tests/class_06.py", - "infile_hash": "f6ac8d14e8dcd9e828294fdc9fa65f930eb30e65094f342cd296cfb2", + "infile_hash": "14c2deb888846d507958aaff8cca0de9ebb3514eb91e631ee38db582", "outfile": null, "outfile_hash": null, "stdout": "asr-class_06-cdc5e29.stdout", - "stdout_hash": "26981374520cb1e14bfbc5b2fb349c66200d649a9f35bb110fc64287", + "stdout_hash": "c91e6e81e2ebbaf0d641e42fad2056b6069db42c53f1ed7a8b442b47", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-class_06-cdc5e29.stdout b/tests/reference/asr-class_06-cdc5e29.stdout index 62e1645a79..367efc3c11 100644 --- a/tests/reference/asr-class_06-cdc5e29.stdout +++ b/tests/reference/asr-class_06-cdc5e29.stdout @@ -178,6 +178,22 @@ (SymbolTable 6 { + _lpython_return_variable: + (Variable + 6 + _lpython_return_variable + [] + ReturnVar + () + () + Default + (Integer 4) + () + Source + Public + Required + .false. + ), i: (Variable 6 @@ -238,7 +254,7 @@ .false. 2 Base )] - () + (Integer 4) Source Implementation () @@ -261,8 +277,19 @@ )] () () - )] - () + ) + (Assignment + (Var 6 _lpython_return_variable) + (StructInstanceMember + (Var 6 i) + 3 x + (Integer 4) + () + ) + () + ) + (Return)] + (Var 6 _lpython_return_variable) Public .false. .false. @@ -293,6 +320,22 @@ Public Required .false. + ), + op: + (Variable + 7 + op + [] + Local + () + () + Default + (Integer 4) + () + Source + Public + Required + .false. ) }) main @@ -327,35 +370,51 @@ ) () ) - (SubroutineCall - 2 f - () - [((Cast - (Var 7 d) - DerivedToBase - (StructType - [(Integer 4)] - [(FunctionType - [(Class - 2 Base + (Assignment + (Var 7 op) + (FunctionCall + 2 f + () + [((Cast + (Var 7 d) + DerivedToBase + (StructType + [(Integer 4)] + [(FunctionType + [(Class + 2 Base + )] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + .false. )] - () - Source - Implementation - () .false. - .false. - .false. - .false. - .false. - [] - .false. - )] - .false. - 2 Base - ) + 2 Base + ) + () + ))] + (Integer 4) () - ))] + () + ) + () + ) + (Assert + (IntegerCompare + (Var 7 op) + Eq + (IntegerConstant 10 (Integer 4)) + (Logical 4) + () + ) () )] ()