You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A more helpful error message than just the generic "Two terms in a row"
could be thrown when the user writes e.g.
foo 42;
as if `foo` were a subroutine, but it's actually some other kind of
bareword such as:
* a constant - `constant foo = ...`
* a sigilless variable - `my \foo = ...`
* a typename - `class foo { ... }`
* a label - `foo: ...`
* a term - `sub term:<foo> { ... }`
The error message could be expanded like this:
===SORRY!=== Error while compiling [...]
Two terms in a row
at [...]
------> say foo⏏ 42;
Note: "foo" is not a subroutine, but a constant declared at [...].
Or in the special case that there actually *is* a subroutine with the
same name in any parent scope (including CORE::), but it's clobbered by
the other bareword:
===SORRY!=== Error while compiling [...]
Two terms in a row
at [...]
------> say foo⏏ 4;
Note: "foo" here does not refer to the subroutine declared
at [...], but to the constant declared at [...].
If the sub is declared inside the setting, the phrase "the subroutine
declared at [...]" could be replaced with "the built-in subroutine".
===SORRY!=== Error while compiling [...]
Constant "foo" is followed by another term at [...]
------> say foo⏏ 4;
If your meant to refer to the subroutine "foo" declared at [...],
then either:
* Use `foo(...)` to disambiguate.
* Rename the constant declared at [...] to not clobber the
subroutine's name.
p6rt
added
the
LTA
Less Than Awesome; typically an error message that could be better
label
Jan 5, 2020
===SORRY!=== Error while compiling -e
Two terms in a row
at -e:1
------> constant foo = 99; foo⏏ 42
expecting any of:
infix
infix stopper
statement end
statement modifier
statement modifier loop
The error message is 100% correct. But if we start changing it… what are we doing it for? So if the user:
declared a constant or something else
then for some reason assumed that a sub with that same name exists?
Migrated from rt.perl.org#131754 (status was 'new')
Searchable as RT131754$
The text was updated successfully, but these errors were encountered: