Attempting to assign to a variable starting with a number leads to cryptic "function argument" error
2x = 5
#ERROR: syntax: "2" is not a valid function argument name
This is a sneaky problem. A novice user doesn't know (and even an intermediate user might puzzle a bit):
1) numbers cannot be used to start names
2) a number juxtaposed with a name is equivalent to *(2, x)
3) *(2, x) on the left-hand-side doesn't perform the operation, but is a function signature
4) therefore, 2x = 5 is attempting to define *(2, x) = 5, and 2 is not a valid function argument name.
Issue brought up in Slack thanks to Yongming Han.
I'm willing to poke around a bit on this one and see what could be done.
Thanks for making this issue; I'm pretty swamped for the next couple of weeks, but would be down to help out after that if there's anything a relative novice like me can help with.
Thanks for the offer @ym-han ! Looks like it was pretty easy to figure out, though mostly because I've recently gotten my hands dirty with the femptolisp-based parser.
For posterity: Other invalid left-hand expressions can lead to the same error message, which are still somewhat cryptic but hopefully clearer to the user why it's invalid, regardless. E.g.:
1 + x = 5
# ERROR: syntax: "1" is not a valid function argument name
1x * 4 = 3
# ERROR: syntax: "(1 * x)" is not a valid function argument name
Maybe something to clean up later?
@ym-han Would you find this good enough to understand what was happening? Unfortunately it seems like it won't be possible to catch it early enough to be sure someone is writing something like 2x = specifically, so I'm thinking this should at least more clearly indicate how Julia is interpreting 2x =?
julia> 2x = 5
ERROR: syntax: invalid function definition; "2" is not a valid function argument name in "(2 * x)"
This looks good enough to me. Thanks for the heroic effort here!!