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

REPL loses custom operators #6446

Open
p6rt opened this issue Aug 15, 2017 · 6 comments
Open

REPL loses custom operators #6446

p6rt opened this issue Aug 15, 2017 · 6 comments
Labels

Comments

@p6rt
Copy link

@p6rt p6rt commented Aug 15, 2017

Migrated from rt.perl.org#131900 (status was 'open')

Searchable as RT131900$

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 15, 2017

From tonnerre.p@gmail.com

Hi,

context is :
MBP running macOS Sierra 10.12.6
RakudoStar dmg installed
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.

When executing the following commands under REPL, i got that issue :

sub postfix​:<€> (Int $n) {2*$n};
sub postfix​:<€> (Int $n) { #`(Sub+{Precedence}|140257667062944) ... }
say 21€
===SORRY!=== Error while compiling​:
Bogus postfix
------> say 21
  expecting any of​:
  infix
  infix stopper
  postfix
  statement end
  statement modifier
  statement modifier loop

Running the same statements into a script is working fine :
#!/usr/bin/env perl6

sub postfix​:<€> (Int $n) {2*$n}

say 21€;

./operators.pl6
42

Regards

Patrick

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 15, 2017

From @lizmat

This appears to be forgetfulness of the REPL from one input to the next. If you put it on the same line, it *does* work​:

sub postfix​:<€> (Int $n) {2*$n}; say 42€
84

So this boils down to a much more generic issue, for which we already have tickets I believe.

On 15 Aug 2017, at 14​:25, Patrick Tonnerre (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Patrick Tonnerre
# Please include the string​: [perl #​131900]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=131900 >

Hi,

context is :
MBP running macOS Sierra 10.12.6
RakudoStar dmg installed
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.

When executing the following commands under REPL, i got that issue :

sub postfix​:<€> (Int $n) {2*$n};
sub postfix​:<€> (Int $n) { #`(Sub+{Precedence}|140257667062944) ... }
say 21€
===SORRY!=== Error while compiling​:
Bogus postfix
------> say 21
expecting any of​:
infix
infix stopper
postfix
statement end
statement modifier
statement modifier loop

Running the same statements into a script is working fine :
#!/usr/bin/env perl6

sub postfix​:<€> (Int $n) {2*$n}

say 21€;

./operators.pl6
42

Regards

Patrick

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 15, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 16, 2017

From tonnerre.p@gmail.com

It works, thank you

Le 15 août 2017 à 21​:06, Elizabeth Mattijsen via RT <perl6-bugs-followup@​perl.org> a écrit :

This appears to be forgetfulness of the REPL from one input to the next. If you put it on the same line, it *does* work​:

sub postfix​:<€> (Int $n) {2*$n}; say 42€
84

So this boils down to a much more generic issue, for which we already have tickets I believe.

On 15 Aug 2017, at 14​:25, Patrick Tonnerre (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Patrick Tonnerre
# Please include the string​: [perl #​131900]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=131900 >

Hi,

context is :
MBP running macOS Sierra 10.12.6
RakudoStar dmg installed
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.

When executing the following commands under REPL, i got that issue :

sub postfix​:<€> (Int $n) {2*$n};
sub postfix​:<€> (Int $n) { #`(Sub+{Precedence}|140257667062944) ... }
say 21€
===SORRY!=== Error while compiling​:
Bogus postfix
------> say 21
expecting any of​:
infix
infix stopper
postfix
statement end
statement modifier
statement modifier loop

Running the same statements into a script is working fine :
#!/usr/bin/env perl6

sub postfix​:<€> (Int $n) {2*$n}

say 21€;

./operators.pl6
42

Regards

Patrick

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 16, 2017

From @lizmat

Further datapoints​:

$ perl6
To exit type 'exit' or '^D'

sub postfix​:<€> (Int $n) {2*$n}; say 42€
84
say postfix​:<€> (42)
84

So, the sub *does* survive from one call to the next. It only loses the grammar adaptations that defining a sub postfix​:<> do.

On 15 Aug 2017, at 21​:06, Elizabeth Mattijsen <liz@​dijkmat.nl> wrote​:

This appears to be forgetfulness of the REPL from one input to the next. If you put it on the same line, it *does* work​:

sub postfix​:<€> (Int $n) {2*$n}; say 42€
84

So this boils down to a much more generic issue, for which we already have tickets I believe.

On 15 Aug 2017, at 14​:25, Patrick Tonnerre (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Patrick Tonnerre
# Please include the string​: [perl #​131900]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=131900 >

Hi,

context is :
MBP running macOS Sierra 10.12.6
RakudoStar dmg installed
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.

When executing the following commands under REPL, i got that issue :

sub postfix​:<€> (Int $n) {2*$n};
sub postfix​:<€> (Int $n) { #`(Sub+{Precedence}|140257667062944) ... }
say 21€
===SORRY!=== Error while compiling​:
Bogus postfix
------> say 21
expecting any of​:
infix
infix stopper
postfix
statement end
statement modifier
statement modifier loop

Running the same statements into a script is working fine :
#!/usr/bin/env perl6

sub postfix​:<€> (Int $n) {2*$n}

say 21€;

./operators.pl6
42

Regards

Patrick

@p6rt
Copy link
Author

@p6rt p6rt commented Sep 17, 2017

From @lefth

The following code works fine if run in a script or with `perl6 -e '...'`,
but fails when run in the REPL​:

class KG { has $.amount; }
sub postfix​:<kg>(Numeric $amount) { KG.new(​:$amount); }
say 10kg;

# Output from perl6 -e​:
# KG.new(amount => 10)

# Output from the REPL is​:
# ===SORRY!=== Error while compiling​:
# Confused
# ------> say 10g;

Interestingly, if a postfix operator like this is exported by a module
which is loaded by the REPL, the REPL can successfully parse that operator
just once, after which it will fail with an error similar to the above.

I'm using Rakudo version 2017.08-96-ge5a600997 built on MoarVM version
2017.08.1-135-ge86428d4 implementing Perl 6.c.

@p6rt p6rt added the REPL 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.