UnionCompilerDesign / compiler_core

The core of the compiler, runtime, and builder setup.
MIT License
1 stars 1 forks source link

STS Incorrect variable initialization #126

Closed Dalyj24 closed 3 weeks ago

Dalyj24 commented 3 weeks ago

Details

The deeper equality revealed that a test which appeared to pass in sym_table_stack_tests actually was failing without our knowledge. The test test_variable_initialization_sym_table fails because the returned STS has a boolean value with a value of an ASTNode that contains a Literal("true") instead of just containing a value of StrValue("true"), you can check this yourself by running the test.

Edit sym_table_init inside of symbol_table_statement so that if the value is simple (like just plain true/false or an int or something like that) then collect it inside a StrValue, and only if the value is complex/needs to be evaluated to know the answer should you collect it in a Node like it is currently.

Issue Type

Requirements

Fix the STS initialization function to make simple values be collected in a StrValue, else collect it in a Node Fix the test to run Make new tests that test the complex functionality

Notes

Could probably use the structure of ASTNodes to help find what's "complex" and what isn't, like a BinaryExpression node would be complex and an AsignedValue with Literal("true") would be simple.