PlutoLang / Pluto

A superset of Lua 5.4 with a focus on general-purpose programming.
https://pluto-lang.org/docs/Introduction
MIT License
338 stars 20 forks source link

Require $define statement to have a righthand side #834

Closed Sainan closed 2 months ago

Sainan commented 2 months ago

Coming from C/C++, this is a very obvious mistake to make, and unfortunately the error reporting for it right now is very confusing. This should hopefully be a bit better. Also fixes some longstanding issues regarding how we convert tokens to strings.


$define MAGIC 69
print(MAGIC)
basic.pluto:1: '=' expected near '69'
    1 | $define MAGIC 69
      | ^^^^^^^^^^^^^^^^ here: this is invalid syntax.

$define MAGIC
print(MAGIC)
basic.pluto:2: '=' expected near 'print'
    2 | print(MAGIC)
      | ^^^^^^^^^^^^ here: this is invalid syntax.