diff --git a/src/util/fmterr.nim b/src/util/fmterr.nim index ae9c757..f6fc37d 100644 --- a/src/util/fmterr.nim +++ b/src/util/fmterr.nim @@ -42,10 +42,13 @@ proc print*(exc: CompileError) = ## Prints a formatted error message ## for compilation errors to stderr var file = exc.file - if file notin ["", ""]: + var contents: string + if file notin ["", "", "stdin"]: file = relativePath(exc.file, getCurrentDir()) - printError(file, readFile(file).splitLines()[exc.line - 1].strip(chars={'\n'}), - exc.line, exc.node.getRelativeBoundaries(), exc.function, + contents = readFile(file).splitLines()[exc.line - 1].strip(chars={'\n'}) + else: + contents = "" + printError(file, contents, exc.line, exc.node.getRelativeBoundaries(), exc.function, exc.msg)