Closed perimosocordiae closed 2 years ago
The failure happens when looking up begin
on this line: https://github.com/asoffer/Icarus/blob/8d52767957c13acb6b5892dd886437e891a347a6/examples/mandelbrot.ic#L51
After a few more lookups, it somehow sees this state
identifier:
https://github.com/asoffer/Icarus/blob/8d52767957c13acb6b5892dd886437e891a347a6/examples/mandelbrot.ic#L61
And later, it sees linspace_state
here:
https://github.com/asoffer/Icarus/blob/8d52767957c13acb6b5892dd886437e891a347a6/examples/mandelbrot.ic#L49
But it never sees the parameters to that jump block, so it eventually runs out of places to look and crashes. Here's the full set of keys in the decls_
map where the failing lookup is attempted:
[139737886926664 compiler/context.cc:143 decls] Looking up begin@<0:918>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:877>
[139737886926664 compiler/context.cc:145 decls] -> linspace_state@<0:885>
[139737886926664 compiler/context.cc:145 decls] -> complex@<0:216>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:1161>
[139737886926664 compiler/context.cc:145 decls] -> linspace_state@<0:819>
[139737886926664 compiler/context.cc:145 decls] -> linspace@<0:1312>
[139737886926664 compiler/context.cc:145 decls] -> x@<0:1104>
[139737886926664 compiler/context.cc:145 decls] -> complex@<0:116>
[139737886926664 compiler/context.cc:145 decls] -> linspace_state@<0:1134>
[139737886926664 compiler/context.cc:145 decls] -> complex@<0:382>
[139737886926664 compiler/context.cc:145 decls] -> complex@<0:204>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:1007>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:1040>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:1188>
[139737886926664 compiler/context.cc:145 decls] -> complex@<0:192>
[139737886926664 compiler/context.cc:145 decls] -> complex@<0:370>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:1260>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:1227>
[139737886926664 compiler/context.cc:145 decls] -> state@<0:1205>
[139737886926664 compiler/context.cc:145 decls] -> linspace_state@<0:775>
[139737886926664 compiler/context.cc:145 decls] -> complex@<0:513>
[139737886926664 compiler/context.cc:150 decls] Identifier begin@<0:918> not found
The ->
entries are the keys of the decls_
map, with the start of their source location annotated (@<0:N>
means at byte offset N in mandelbrot.ic).
This is what's currently breaking examples/mandelbrot.ic.
If you move the
linspace
scope to a separate module and export it, then have the mandelbrot example load from there, everything works.As it stands, the all-in-one-file approach fails when looking up the decl for the "begin" identifier. It runs through the whole chain of parent contexts until the parent() returns nullptr, at which point we crash (or start reading garbage memory and hopefully crash).