remoo69 / Compiler-Sheesh

Compiler for the self-developed language Sheesh#.
MIT License
2 stars 1 forks source link

detecting type mismatch in lower precedence scope #49

Open jldav1d opened 2 weeks ago

jldav1d commented 2 weeks ago

Expected: Semantic Error Actual: No Semantic Errors

Code:

sheesh(){
    whole a = 2#
    kung(cap){
        a = cap#
    }
    a = 10#
}

Global variable re-declared as a parameter in a function, this should also an error:

whole x#

def whole func(whole x){
    yeet x#
}

sheesh(){
    yeet#
}

The code above crashes the compiler, as with any code that has functions with it.

Error Message:

Traceback (most recent call last):
  File "C:\Python312\Lib\tkinter\__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\Sheesh# Compiler.py", line 140, in run_parser
    compiler.compile()
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\source\core\compile.py", line 43, in compile
    self.parser.parse()
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\source\SyntaxAnalyzer\Parser.py", line 119, in parse
    self.semantic.analyze()
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\source\SemanticAnalyzer\SemanticAnalyzer.py", line 130, in analyze
    self.routines[self.current_node.root]()
  File "C:\Users\David\Downloads\sheesh#\Compiler-Sheesh\source\SemanticAnalyzer\SemanticAnalyzer.py", line 272, in control_flow_statement
    if self.current_node.children[2].type=="Identifier" and self.current_node.children[0].value=="choose":
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AST' object has no attribute 'type'