jakt
jakt copied to clipboard
selfhost/typechecker: Prelude structs aren't included in root module
After debugging a failed index to an array that happens when trying to typecheck the
first call to flag
in selfhost/main.jakt
(line 26), I injected a couple of print
statements and found that, to my surprise, the structures
array in the module
with module ID 0 (i.e the root module) is empty. Since main.jakt
doesn't define any
structs or classes it would be correct if it was an imported module, but since
it's the root module then it should've had the prelude types like Optional
, Array
...
If you're interested, the access comes from this code: https://github.com/SerenityOS/jakt/blob/d6e538a29f7860f973ef62daf98ac2fe9da8e777/selfhost/typechecker.jakt#L2540-L2544 that gets the structure so it can get the name in case it has to produce an error.
A reduced sample:
function a(args: [String]) {}
function main() {
let args = ["1", "2", "3"]
a(args)
}
fixed as of 1ea81c6