Skip Menu |
Report information
Id: 131754
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: smls75 [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



To: Rakudo Bugtracker <rakudobug [...] perl.org>
Subject: [LTA] Error message when using a term bareword like a subroutine
Date: Sat, 15 Jul 2017 09:46:50 +0200
From: Sam S <smls75 [...] gmail.com>
Download (untitled) / with headers
text/plain 1.1k
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".
Download (untitled) / with headers
text/plain 376b
A possibly better way to phrase it: ===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.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org