diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index b09000d005..399b07d1a5 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -1862,6 +1862,12 @@ proc genTypeInfoV2Impl(m: BModule; t, origType: PType, name: Rope; info: TLineIn if t.kind == tyObject and t.baseClass != nil and optEnableDeepCopy in m.config.globalOptions: discard genTypeInfoV1(m, t, info) +proc myModuleOpenForCodegen(m: BModule; idx: FileIndex): bool {.inline.} = + if moduleOpenForCodegen(m.g.graph, idx): + result = idx.int < m.g.modules.len and m.g.modules[idx.int] != nil + else: + result = false + proc genTypeInfoV2(m: BModule; t: PType; info: TLineInfo): Rope = let origType = t # distinct types can have their own destructors @@ -1890,7 +1896,7 @@ proc genTypeInfoV2(m: BModule; t: PType; info: TLineInfo): Rope = m.typeInfoMarkerV2[sig] = result let owner = t.skipTypes(typedescPtrs).itemId.module - if owner != m.module.position and moduleOpenForCodegen(m.g.graph, FileIndex owner): + if owner != m.module.position and myModuleOpenForCodegen(m, FileIndex owner): # make sure the type info is created in the owner module discard genTypeInfoV2(m.g.modules[owner], origType, info) # reference the type info as extern here @@ -1975,7 +1981,7 @@ proc genTypeInfoV1(m: BModule; t: PType; info: TLineInfo): Rope = return prefixTI(result) var owner = t.skipTypes(typedescPtrs).itemId.module - if owner != m.module.position and moduleOpenForCodegen(m.g.graph, FileIndex owner): + if owner != m.module.position and myModuleOpenForCodegen(m, FileIndex owner): # make sure the type info is created in the owner module discard genTypeInfoV1(m.g.modules[owner], origType, info) # reference the type info as extern here diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 5c52c10d01..aff8a6a53d 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -30,7 +30,6 @@ proc toLowerAscii(a: var string) {.inline.} = proc flushDot*(conf: ConfigRef) = ## safe to call multiple times - # xxx one edge case not yet handled is when `printf` is called at CT with `compiletimeFFI`. let stdOrr = if optStdout in conf.globalOptions: stdout else: stderr let stdOrrKind = toStdOrrKind(stdOrr) if stdOrrKind in conf.lastMsgWasDot: @@ -52,7 +51,7 @@ proc makeCString*(s: string): Rope = result = newStringOfCap(int(s.len.toFloat * 1.1) + 1) result.add("\"") for i in 0..