Skip to content

Commit

Permalink
Fix file names in assert macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
FeepingCreature committed May 26, 2023
1 parent 421a799 commit ec443dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/neat/base.nt
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ abstract class CompilerBase
// for std.macro.cimport
string[] cFlags;

FileIdTable fileIdTable;

// parser
abstract (Parser | fail Error) createParser(string filename, string fulltext);

Expand Down
2 changes: 0 additions & 2 deletions src/neat/compiler.nt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class CompilerImpl : CompilerBase

GlobalUniqCounter glob;

FileIdTable fileIdTable;

this(this.defaultImports, this.modParseConfig, this.cFlags, this.workPool, string[int] inheritedFileIds) {
this.mutex = new Mutex;
this.glob = new GlobalUniqCounter;
Expand Down
6 changes: 4 additions & 2 deletions src/std/macro/assert.nt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class ASTAssertion : ASTStatement

auto ifFailed = dispatch(context, test)?;
if (auto ifFailed = ifFailed) {
string failedMsg = locRange.toString ~ ": assertion failed: " ~ exprText ~ ", because ";
string failedMsg = locRange.repr(context.compiler.fileIdTable) ~
": assertion failed: " ~ exprText ~ ", because ";
context = context.withNamespace(context.compiler.exprAlias(
context.namespace, "ifFailed", ifFailed));
context = context.withNamespace(context.compiler.exprAlias(
Expand All @@ -196,7 +197,8 @@ class ASTAssertion : ASTStatement
auto assertTestStmt = assertTest.compile(context)?;
return StatementCompileResult(assertTestStmt.statement, context.namespace);
}
string failedMsg = locRange.toString ~ ": assertion failed: '" ~ exprText ~ "' was false";
string failedMsg = locRange.repr(context.compiler.fileIdTable) ~
": assertion failed: '" ~ exprText ~ "' was false";
context = context.withNamespace(context.compiler.exprAlias(
context.namespace,
"failedMsg",
Expand Down

0 comments on commit ec443dd

Please sign in to comment.