ullage icon indicating copy to clipboard operation
ullage copied to clipboard

Functions Declarations Don't Properly Obey Scopes

Open iwillspeak opened this issue 6 years ago • 0 comments

When defining nested functions other functions scopes can poison inner ones:

fn foo(): Number
   100
end

print foo() # => 100

fn bar(): Number
   print foo()
   fn foo(): Number
   	  -934
   end
   print foo()
end

let b = bar() # => -934
              # => -934

print b == foo() # => false

This test case will currently fail. The inner foo declaration will be emitted to the same LLVM function as the outer one. The solution is to mangle each function's name when emitting the LLVM function. Probably best grouped together with #22 and #17.

Maybe we want to keep a side-table of information about each function (return type, parameters, mangled name etc.) in the lower context. We would need a consistent and quick way of finding these declarations.

iwillspeak avatar Jan 27 '19 09:01 iwillspeak