Skip to content

Commit

Permalink
fix when parentModule not found
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed Oct 11, 2023
1 parent 6235d8f commit 9b1ecbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/modules/modulegraphs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ proc parentModule*(g: ModuleGraph; fileIdx: FileIndex): FileIndex =
if fileIdx.int32 >= 0 and fileIdx.int32 < g.ifaces.len and g.ifaces[fileIdx.int32].module != nil:
result = fileIdx
else:
result = g.inclToMod.getOrDefault(fileIdx)
result = g.inclToMod.getOrDefault(fileIdx, InvalidFileIdx)

proc markDirty*(g: ModuleGraph; fileIdx: FileIndex) =
let m = g.getModule fileIdx
Expand Down
4 changes: 3 additions & 1 deletion compiler/tools/suggest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ proc executeCmd*(cmd: IdeCmd, file, dirtyfile: AbsoluteFile, line, col: int;
dirtyfile.isEmpty:
discard "no need to recompile anything"
else:
let modIdx = graph.parentModule(dirtyIdx)
var modIdx = graph.parentModule(dirtyIdx)
if modIdx == InvalidFileIdx:
modIdx = dirtyIdx
graph.markDirty dirtyIdx
graph.markClientsDirty dirtyIdx
# partially recompiling the project means that that VM and JIT state
Expand Down

0 comments on commit 9b1ecbd

Please sign in to comment.