From 6f5acd211cef377d8f460d0e80611cb5ba2f4422 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sat, 28 Aug 2021 17:41:13 -0700 Subject: [PATCH] fix for IC --- compiler/ast.nim | 6 +++++- compiler/commands.nim | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index b3f37f0858a1e..5893a5671612a 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -997,11 +997,15 @@ type Gconfig = object # we put comments in a side channel to avoid increasing `sizeof(TNode)`, which # reduces memory usage given that `PNode` is the most allocated type by far. comments: Table[int, string] # nodeId => comment + useIc*: bool var gconfig {.threadvar.}: Gconfig +proc setUseIc*(useIc: bool) = gconfig.useIc = useIc + proc comment*(n: PNode): string = - if nfHasComment in n.flags: + if nfHasComment in n.flags and not gconfig.useIc: + # IC doesn't track comments, see `packed_ast`, so this could fail result = gconfig.comments[n.nodeId] proc `comment=`*(n: PNode, a: string) = diff --git a/compiler/commands.nim b/compiler/commands.nim index 82e9081525b17..079717862d8dc 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -8,7 +8,7 @@ # # This module handles the parsing of command line arguments. - +from ast import setUseIc # We do this here before the 'import' statement so 'defined' does not get # confused with 'TGCMode.gcMarkAndSweep' etc. @@ -862,6 +862,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "v2": conf.symbolFiles = v2Sf of "stress": conf.symbolFiles = stressTest else: localError(conf, info, "invalid option for --incremental: " & arg) + setUseIc(conf.symbolFiles != disabledSf) of "skipcfg": processOnOffSwitchG(conf, {optSkipSystemConfigFile}, arg, pass, info) of "skipprojcfg":