quint icon indicating copy to clipboard operation
quint copied to clipboard

redefining a function gives a "syntax error"

Open plafer opened this issue 2 years ago • 3 comments

In the repl,

>>> def farenheit(celsius) = celsius * 9 / 5 + 32

>>> def farenheit(celsius) = celsius * 9 / 5 + 32
syntax error: <input>:4:1 - error: Conflicting definitions found for name farenheit in module __REPL
4: def farenheit(celsius) = celsius * 9 / 5 + 32
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<input>:5:1 - error: Conflicting definitions found for name farenheit in module __REPL
5: def farenheit(celsius) = celsius * 9 / 5 + 32
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I get a syntax error, even though my syntax is fine. The error message is super useful; I would just put it in a category other than "syntax".

plafer avatar Dec 15 '22 20:12 plafer

We have discussed the need to allow some form of redefinition or shadowing int he REPL tho. I think it's agreed we need it :)

That said, conflicting definitions in a language that doesn't support shadowing does seem like a syntax error to me. What category would make more sense do you think?

shonfeder avatar Dec 15 '22 20:12 shonfeder

If we agree that "syntax error" means "cannot be parsed"/"cannot be generated by grammar", then this would not be a syntax error. Assuming you want to disallow redefinitions (i.e. not in a REPL), then this error would be caught at some point during semantic analysis, and so any sub-category of "semantic error" would make sense to me.

We have discussed the need to allow some for of redefinition or shadowing int he REPL tho. I think it's agreed we need it :)

That would indeed be great!

plafer avatar Dec 15 '22 21:12 plafer

Ah I see. Yeah, that makes sense to me.

shonfeder avatar Dec 16 '22 03:12 shonfeder