Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro arguments shouldn't care about unterminated strings #1622

Closed
Rangi42 opened this issue Jan 20, 2025 · 2 comments
Closed

Macro arguments shouldn't care about unterminated strings #1622

Rangi42 opened this issue Jan 20, 2025 · 2 comments
Assignees
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM

Comments

@Rangi42
Copy link
Contributor

Rangi42 commented Jan 20, 2025

macro foo
  println \1, " world!"
endm
  foo "hello

macro bar
  println \1 world!"
endm
  bar "goodbye
error: main.asm(4):
    Unterminated string
error: main.asm(4) -> main.asm::foo(2):
    syntax error, unexpected identifier
error: main.asm(4) -> main.asm::foo(2):
    Unterminated string
error: main.asm(9):
    Unterminated string
goodbye world!
error: Assembly aborted (4 errors)!

I don't think that lexing macro arguments should be giving an "unterminated string" error. If/when the argument is expanded, its usage will still give an unterminated string error in context (e.g. when foo "hello expands to println "hello, " world!") -- except for edge cases where the whole point is that it wouldn't (e.g. when bar "hello expands to println "goodbye world!"). For example, the above output would then be:

error: main.asm(4) -> main.asm::foo(2):
    syntax error, unexpected identifier
error: main.asm(4) -> main.asm::foo(2):
    Unterminated string
goodbye world!
error: Assembly aborted (2 errors)!
@Rangi42 Rangi42 added bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM labels Jan 20, 2025
@Rangi42 Rangi42 added this to the 0.9.1 milestone Jan 20, 2025
@Rangi42 Rangi42 self-assigned this Jan 20, 2025
@Rangi42
Copy link
Contributor Author

Rangi42 commented Jan 20, 2025

Note that you can currently avoid those "unterminated string" errors by escaping the quotes so they don't start "string within macro arg" logic, e.g. foo \"hello. Given that... maybe we shouldn't count this as a bug after all, but a weird edge test case (#1584)?

@Rangi42
Copy link
Contributor Author

Rangi42 commented Jan 20, 2025

Yeah, this is only even a question for the last argument; for all the rest, it's clear that you need to escape the " to prevent the , from being part of the "string within macro arg".

Also test/asm/raw-macro.args.asm covers this already, so no need to add another weird test case.

@Rangi42 Rangi42 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2025
@Rangi42 Rangi42 removed this from the 0.9.1 milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM
Projects
None yet
Development

No branches or pull requests

1 participant