edubart / nelua-lang

Minimal, efficient, statically-typed and meta-programmable systems programming language heavily inspired by Lua, which compiles to C and native code.
https://nelua.io
MIT License
1.99k stars 64 forks source link

Misleading error when using non-existent += operator #207

Closed IcedQuinn closed 1 year ago

IcedQuinn commented 1 year ago

In the following code:

local function round32(acc, input: uint32): uint32 <inline>
  local result = acc
  result += input * xxhash.prime32[2]
  result  = rotl32(result, 13)
  result *= xxhash.prime32[1]
end

This can create the following misleading error:

xxhash.nelua:76:3: syntax error: expected `end` keyword to close a statement block
  result += input * xxhash.prime32[2]
Its-Kenta commented 1 year ago

Yeah it's actually something that has been bothering me as of late with misleading errors that have nothing to do with the bug itself. It really makes the development a little bit... Tricky?

Its-Kenta commented 1 year ago

Are there any updates on when this might get fixed? Such misleading errors makes debugging difficult…

edubart commented 1 year ago

I changed the error message to:

test.nelua:20:3: syntax error: unexpected statement syntax, did you forgot an `end` or are using an invalid syntax?
  result += input * xxhash.prime32[2]

I hope that makes the error message more clear, that you attempted to use an invalid syntax. The parser has no concept of compound assignment operators, so I don't see how we could improve more.