diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 5ddf78a769..7c5286d906 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -690,7 +690,7 @@ proc genRaiseStmt(p: BProc, t: PNode) = lineCg(p, cpsStmts, "#raiseExceptionEx((#Exception*)$1, $2, $3, $4, $5);$n", [e, makeCString(typ.sym.name.s), makeCString(if p.prc != nil: p.prc.name.s else: p.module.module.name.s), - makeCString(toFileName(p.config, t.info)), toLinenumber(t.info)]) + quotedFilename(p.config, t.info), toLinenumber(t.info)]) if optNimV2 in p.config.globalOptions: lineCg(p, cpsStmts, "$1 = NIM_NIL;$n", [e]) else: diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 436260d4b2..892f1af36e 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -40,9 +40,8 @@ proc newFileInfo(fullPath: AbsoluteFile, projPath: RelativeFile): TFileInfo = #shallow(result.fullPath) result.projPath = projPath #shallow(result.projPath) - let fileName = fullPath.extractFilename - result.shortName = fileName.changeFileExt("") - result.quotedName = fileName.makeCString + result.shortName = fullPath.extractFilename + result.quotedName = result.shortName.makeCString result.quotedFullName = fullPath.string.makeCString result.lines = @[] when defined(nimpretty): @@ -165,7 +164,11 @@ template toFilename*(conf: ConfigRef; fileIdx: FileIndex): string = if fileIdx.int32 < 0 or conf == nil: "???" else: - conf.m.fileInfos[fileIdx.int32].projPath.string + conf.m.fileInfos[fileIdx.int32].shortName + +proc toProjPath*(conf: ConfigRef; fileIdx: FileIndex): string = + if fileIdx.int32 < 0 or conf == nil: "???" + else: conf.m.fileInfos[fileIdx.int32].projPath.string proc toFullPath*(conf: ConfigRef; fileIdx: FileIndex): string = if fileIdx.int32 < 0 or conf == nil: result = "???" @@ -195,6 +198,9 @@ proc toFullPathConsiderDirty*(conf: ConfigRef; fileIdx: FileIndex): AbsoluteFile template toFilename*(conf: ConfigRef; info: TLineInfo): string = toFilename(conf, info.fileIndex) +template toProjPath*(conf: ConfigRef; info: TLineInfo): string = + toProjPath(conf, info.fileIndex) + template toFullPath*(conf: ConfigRef; info: TLineInfo): string = toFullPath(conf, info.fileIndex) @@ -204,7 +210,7 @@ template toFullPathConsiderDirty*(conf: ConfigRef; info: TLineInfo): string = proc toMsgFilename*(conf: ConfigRef; info: FileIndex): string = let absPath = toFullPath(conf, info) - relPath = toFilename(conf, info) + relPath = toProjPath(conf, info) result = if (optListFullPaths in conf.globalOptions) or (relPath.len > absPath.len) or (relPath.count("..") > 2): @@ -560,8 +566,9 @@ template internalAssert*(conf: ConfigRef, e: bool) = if not e: internalError(conf, $instantiationInfo()) proc quotedFilename*(conf: ConfigRef; i: TLineInfo): Rope = - assert i.fileIndex.int32 >= 0 - if optExcessiveStackTrace in conf.globalOptions: + if i.fileIndex.int32 < 0: + result = makeCString "???" + elif optExcessiveStackTrace in conf.globalOptions: result = conf.m.fileInfos[i.fileIndex.int32].quotedFullName else: result = conf.m.fileInfos[i.fileIndex.int32].quotedName