Skip to content

Commit 4c9ba99

Browse files
committed
fix: fix line number in error msgs within asm contexts
1 parent 5801c2a commit 4c9ba99

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/arch/z80/backend/generic.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,6 @@ def _inline(ins):
540540

541541
i = 0
542542
while i < len(tmp):
543-
if not tmp[i]: # discard empty lines
544-
tmp.pop(i)
545-
continue
546-
547543
if not tmp[i] or tmp[i][0] == ";": # a comment
548544
i += 1
549545
continue

src/arch/z80/translator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def visit_ITALIC(self, node):
916916
# -----------------------------------------------------------------------------------------------------
917917
def visit_ASM(self, node):
918918
EOL = "\n"
919-
self.ic_inline(f'#line {node.lineno + 1} "{node.filename}"')
919+
self.ic_inline(f'#line {node.lineno} "{node.filename}"')
920920
self.ic_inline(node.asm)
921921
self.ic_inline(f'#line {node.lineno + len(node.asm.split(EOL))} "{node.filename}"')
922922

tests/functional/test_errmsg.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ line_number_after_macro.bas:11: error: Syntax Error. Unexpected token '+' <PLUS>
225225
>>> process_file('zx48k/tap_asm_error_line.bas', ['-S', '-q'])
226226
tap_asm_error_line.bas:3: error: Syntax error. Unexpected token '10' [INTEGER]
227227
tap_asm_error_line.bas:7: error: Syntax error. Unexpected token '10' [INTEGER]
228+
>>> process_file('zx48k/tap_errline.bas')
229+
tap_errline.bas:10: error: Syntax error. Unexpected token 'HL' [HL]
228230

229231
# Test error file names
230232
>>> process_file('zx48k/bad_fname_err0.bas', ['-S', '-q'])
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
asm
3+
push hl
4+
push de
5+
push af
6+
7+
ld hl,16384
8+
ld de,16385
9+
ld a,(hl)
10+
ex hl,de
11+
12+
pop af
13+
pop de
14+
pop hl
15+
end asm

0 commit comments

Comments
 (0)