jakt icon indicating copy to clipboard operation
jakt copied to clipboard

selfhost/typechecker: Prelude structs aren't included in root module

Open cg-jl opened this issue 2 years ago • 1 comments

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.

cg-jl avatar Jun 28 '22 18:06 cg-jl

A reduced sample:

function a(args: [String]) {}

function main() {
    let args = ["1", "2", "3"]
    a(args)
}

cg-jl avatar Jun 28 '22 18:06 cg-jl

fixed as of 1ea81c6

lanmonster avatar Sep 01 '22 16:09 lanmonster