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

LTA error message "Undeclared routine" rather than "Two terms in a row" from dropped comma on say hash #5533

Open
doomvox opened this issue Feb 26, 2024 · 1 comment
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@doomvox
Copy link

doomvox commented Feb 26, 2024

The Problem

Given a simple hash:

my %h = A => 1;

If you're trying to type:

say "output: ", %h<A>;

But drop the comma separator, you get an "Undeclared routine" error:

 say "output: " %h<A>;
 # Undeclared routine:
 #     h used at line 16. Did you mean 'HOW'?

Rather than the expected "Two terms in a row", which
you'll see if you do something similar with an array:

    my @a = < A B C >;  
    say "output: " @a[1];
    # Two terms in a row

Environment

  • Operating system:

    Debian 5.10.209-2 (2024-01-31) x86_64 GNU/Linux

  • Compiler version (rakudo -v or raku -v):

    raku --version
    Welcome to Rakudo™ v2023.02.
    Implementing the Raku® Programming Language v6.d.
    Built on MoarVM version 2023.02.

@jnthn
Copy link
Member

jnthn commented Feb 26, 2024

The difference is because % is an operator (modulo), and so an infix is found, and the next term is also syntactically well-formed (listop function syntax for h and indexing its result). Since a function may be post-declared, then an error is only produced once parsing is done and no h was found.

@ab5tract ab5tract added the LTA Less Than Awesome; typically an error message that could be better label Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

3 participants