From 94cee7d2584608f9797269ad02ad0566d886da75 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 14 Mar 2026 13:01:46 +0000 Subject: [PATCH] Fix string interpolation in error messages --- asm.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/asm.js b/asm.js index 242f9fd..c9d42eb 100644 --- a/asm.js +++ b/asm.js @@ -306,7 +306,7 @@ class Parser { this.state = State.TOP; } else { this.mem.init = this.integer(token) ?? console.error( - `ERROR: Invalid initial size {token} in .mem`); + `ERROR: Invalid initial size ${token} in .mem`); this.state = State.MEM_MAX; } } @@ -316,7 +316,7 @@ class Parser { return this.mem_action(); } else { this.mem.max = this.integer(token) ?? console.error( - `ERROR: Invalid maximum size {token} in .mem`); + `ERROR: Invalid maximum size ${token} in .mem`); this.mem.flags |= mem_flags.max; this.state = State.MEM_FLAGS; } @@ -328,7 +328,7 @@ class Parser { } else { for (const flag of token.split(",")) { this.mem.flags |= mem_flags[flag] ?? console.error( - `ERROR: Invalid flag {flag} in .mem`); + `ERROR: Invalid flag ${flag} in .mem`); } this.state = State.TOP; return this.mem_action(); @@ -354,7 +354,7 @@ class Parser { this.state = State.TOP; } else if (token.string == undefined) { console.error( - `ERROR: Unexpected token {token} in .import: expected` + `ERROR: Unexpected token ${token} in .import: expected` + " module string"); this.import = undefined; this.state = State.TOP; @@ -405,7 +405,8 @@ class Parser { this.state = State.TOP; } else { this.global.type = types[token] ?? console.error( - `ERROR: Unexpected token {token} in .global: expected type`); + `ERROR: Unexpected token ${token} in .global: ` + + "expected type"); this.state = State.GLOBAL_INIT; } } @@ -420,7 +421,7 @@ class Parser { this.state = State.TOP; } else { const value = this.integer(token) ?? console.error( - `ERROR: Unexpected token {token} in .global: expected` + `ERROR: Unexpected token ${token} in .global: expected` + " initial value"); const const_opcode = const_opcodes[this.global.type]; this.global.init = [ const_opcode, value, opcodes["end"] ]; @@ -444,7 +445,8 @@ class Parser { const value = this.integer(token); if (value == null) { console.error( - `ERROR: Unexpected token {token} in .mem: expected address`); + `ERROR: Unexpected token ${token} in .mem: ` + + "expected address"); this.at = undefined; return; }