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

Errors for "[[-" While Constructing Array #2603

Open
bobnewgard opened this issue Jan 11, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@bobnewgard
Copy link

commented Jan 11, 2019

The Problem

The string "[[-" seems to be a bug for the perl6 compiler in Rakudo Star 2018.10. To mitigate, either a space character between the '[' characters, a space character before the '-' or parenthesis around the negative first value may be used.

Expected Behavior

No compiler errors.

Actual Behavior

% env-p6 perl6 x/bracket-bracket-dash.pl6
===SORRY!=== Error while compiling /home/bobn/git/P6-HW-Bit/x/bracket-bracket-dash.pl6
Unable to parse expression in bracketed infix; couldn't find final ']' (corresponding starter was at line 9)
at /home/bobn/git/P6-HW-Bit/x/bracket-bracket-dash.pl6:9
------> [[-⏏2,-2],[2,-2],[7,-7]],

Steps to Reproduce

  1. Create file x/bracket-bracket-dash.pl6
    #!/usr/bin/env perl6
    use v6;
    use Test;
    constant TEST_VECTORS = [
    [[2,-2],[2,-2],[7,-7]],
    [[-2,-2],[2,-2],[7,-7]],
    ];
    done-testing;
  2. Check environment
    % env-p6
    usage:
    env-p6 <Rakudo*-executable> <Rakudo*-parameters>
    env-p6 eval '<Rakudo*-executable> <Rakudo*-parameters>'
    Rakudo*-executables are perl6, zef...
    RS_EXEC_VER is 2018.10 (default)
    supported values are: 2016.04 2018.01 2018.10
    exports environment variables
    PATH is "/opt/Rakudo/2018.10/bin:/opt/Rakudo/2018.10/share/perl6/site/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    use "env-p6 eval '...'" to delay parameter expansion
    e.g. env-p6 eval 'echo $PATH'
    %
  3. Attempt run
    % env-p6 perl6 --ll-exception x/bracket-bracket-dash.pl6
    Unable to parse expression in bracketed infix; couldn't find final ']' (corresponding starter was at line 9)
    at SETTING::src/core/Exception.pm6:57 (/opt/Rakudo/2018.10/share/perl6/runtime/CORE.setting.moarvm:throw)
    from src/Perl6/World.nqp:4914 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/World.moarvm:throw)
    from gen/moar/Perl6-Grammar.nqp:299 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:typed_panic)
    from gen/moar/Perl6-Grammar.nqp:283 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:FAILGOAL)
    from gen/moar/Perl6-Grammar.nqp:4183 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:infixish)
    from gen/moar/Perl6-Grammar.nqp:4277 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:term:sym)
    from gen/moar/stage2/QRegex.nqp:1694 (/opt/Rakudo/2018.10/share/nqp/lib/QRegex.moarvm:!protoregex)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:term)
    from gen/moar/Perl6-Grammar.nqp:4123 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:termish)
    from gen/moar/stage2/NQPHLL.nqp:663 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:nulltermish)
    from gen/moar/stage2/NQPHLL.nqp:985 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:EXPR)
    from gen/moar/Perl6-Grammar.nqp:4163 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:EXPR)
    from gen/moar/Perl6-Grammar.nqp:1452 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:statement)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:semilist)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:circumfix:sym<[ ]>)
    from gen/moar/stage2/QRegex.nqp:1694 (/opt/Rakudo/2018.10/share/nqp/lib/QRegex.moarvm:!protoregex)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:circumfix)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:term:sym)
    from gen/moar/stage2/QRegex.nqp:1694 (/opt/Rakudo/2018.10/share/nqp/lib/QRegex.moarvm:!protoregex)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:term)
    from gen/moar/Perl6-Grammar.nqp:4123 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:termish)
    from gen/moar/stage2/NQPHLL.nqp:985 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:EXPR)
    from gen/moar/Perl6-Grammar.nqp:4163 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:EXPR)
    from gen/moar/Perl6-Grammar.nqp:3455 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:initializer:sym<=>)
    from gen/moar/stage2/QRegex.nqp:1694 (/opt/Rakudo/2018.10/share/nqp/lib/QRegex.moarvm:!protoregex)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:initializer)
    from gen/moar/Perl6-Grammar.nqp:3440 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:type_declarator:sym)
    from gen/moar/stage2/QRegex.nqp:1694 (/opt/Rakudo/2018.10/share/nqp/lib/QRegex.moarvm:!protoregex)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:type_declarator)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:term:sym<type_declarator>)
    from gen/moar/stage2/QRegex.nqp:1694 (/opt/Rakudo/2018.10/share/nqp/lib/QRegex.moarvm:!protoregex)
    from :1 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:term)
    from gen/moar/Perl6-Grammar.nqp:4123 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:termish)
    from gen/moar/stage2/NQPHLL.nqp:985 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:EXPR)
    from gen/moar/Perl6-Grammar.nqp:4163 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:EXPR)
    from gen/moar/Perl6-Grammar.nqp:1452 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:statement)
    from gen/moar/Perl6-Grammar.nqp:1380 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:statementlist)
    from gen/moar/stage2/NQPHLL.nqp:1217 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:LANG)
    from gen/moar/Perl6-Grammar.nqp:1828 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:FOREIGN_LANG)
    from gen/moar/Perl6-Grammar.nqp:1344 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:comp_unit)
    from gen/moar/Perl6-Grammar.nqp:553 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Grammar.moarvm:TOP)
    from gen/moar/stage2/QRegex.nqp:2301 (/opt/Rakudo/2018.10/share/nqp/lib/QRegex.moarvm:parse)
    from gen/moar/stage2/NQPHLL.nqp:2025 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:parse)
    from gen/moar/stage2/NQPHLL.nqp:1941 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:execute_stage)
    from gen/moar/stage2/NQPHLL.nqp:1974 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:run)
    from gen/moar/stage2/NQPHLL.nqp:1977 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:)
    from gen/moar/stage2/NQPHLL.nqp:1963 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:compile)
    from gen/moar/stage2/NQPHLL.nqp:1657 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:eval)
    from gen/moar/stage2/NQPHLL.nqp:1918 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:evalfiles)
    from gen/moar/stage2/NQPHLL.nqp:1841 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:command_eval)
    from src/Perl6/Compiler.nqp:42 (/opt/Rakudo/2018.10/share/nqp/lib/Perl6/Compiler.moarvm:command_eval)
    from gen/moar/stage2/NQPHLL.nqp:1767 (/opt/Rakudo/2018.10/share/nqp/lib/NQPHLL.moarvm:command_line)
    from gen/moar/main.nqp:54 (/opt/Rakudo/2018.10/share/perl6/runtime/perl6.moarvm:MAIN)
    from gen/moar/main.nqp:42 (/opt/Rakudo/2018.10/share/perl6/runtime/perl6.moarvm:)
    from :1 (/opt/Rakudo/2018.10/share/perl6/runtime/perl6.moarvm:)
    from :1 (/opt/Rakudo/2018.10/share/perl6/runtime/perl6.moarvm:)
    %

Environment

  • Operating system: Debian 9.x
    % uname -a
    Linux sake 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
    %

  • Compiler version (perl6 -v):
    % env-p6 perl6 -v
    This is Rakudo Star version 2018.10 built on MoarVM version 2018.10
    implementing Perl 6.c.
    %

@jnthn

This comment has been minimized.

Copy link
Member

commented Jan 11, 2019

A [-] in that position would be a reduction operator. We do some limited lookahead to avoid obvious cases of collision with an array starting with a negative integer, but apparently this one isn't obvious enough by the current rules. :-) Most probably we can tweak the heuristic to do what was intended in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.