Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message when using a term bareword as if it were a subroutine #6393

Open
p6rt opened this issue Jul 15, 2017 · 2 comments
Open

Error message when using a term bareword as if it were a subroutine #6393

p6rt opened this issue Jul 15, 2017 · 2 comments
Labels
LTA

Comments

@p6rt
Copy link

@p6rt p6rt commented Jul 15, 2017

Migrated from rt.perl.org#131754 (status was 'new')

Searchable as RT131754$

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Jul 15, 2017

From @smls

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".

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Jul 15, 2017

From @smls

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.

@p6rt p6rt added the LTA label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.