nimscript: fix compiler crash with .header
procs
#800
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix the compiler crashing when running NimScript files that directly
contain procedure definitions using the
.header
or.dynlib
pragma.Details
The module of a NimScript didn't use its own
IdGenerator
, but insteadre-used the
IdGenerator
instance belonging to theModuleGraph
. Apartfrom leading to all symbols created as part of semantically analysing
the module being not attached to any module, this also caused an
IndexDefect
when processing a.header
/.dynlib
pragma, as there themodule ID provided by the
IdGenerator
(which is -1 for theModuleGraph
's) is used as an index into to theTLib
storage.A dedicated
IdGenerator
is now created for a NimScript file, bothfixing the crash and guaranteeing that the module ID provided by a
PContext
's ID generator is a validFileIndex
.