ref: b07aa00d5cfda645978747d25c20643b7cc1ee7e
parent: 71d8aeb4c276d29764bf0f76879a2b6047c85803
author: Jakub Kądziołka <kuba@kadziolka.net>
date: Mon Oct 12 08:27:06 EDT 2020
Don't overwrite symbol when it's not allowed When a user tried to overwrite a builtin symbol, it would change its type despite the error, making the second try succeed. This is problematic, as the location of a builtin symbol cannot be updated.
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -426,6 +426,7 @@
symName, sym->type == SYM_LABEL ? "label" : "constant");
dumpFilename(sym);
putc('\n', stderr);
+ return sym;
} else {
/* TODO: can the scope be incorrect when taking over refs? */
updateSymbolFilename(sym);
--- /dev/null
+++ b/test/asm/narg-overwrite.asm
@@ -1,0 +1,2 @@
+_NARG = 0
+_NARG = 0
--- /dev/null
+++ b/test/asm/narg-overwrite.err
@@ -1,0 +1,5 @@
+ERROR: narg-overwrite.asm(1):
+ '_NARG' already defined as constant at <builtin>
+ERROR: narg-overwrite.asm(2):
+ '_NARG' already defined as constant at <builtin>
+error: Assembly aborted (2 errors)!