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

'say 1 if 0 if 1 { say 3 }' parsing bug in Rakudo (and STD) #1770

Closed
p6rt opened this issue May 20, 2010 · 8 comments
Closed

'say 1 if 0 if 1 { say 3 }' parsing bug in Rakudo (and STD) #1770

p6rt opened this issue May 20, 2010 · 8 comments

Comments

@p6rt
Copy link

p6rt commented May 20, 2010

Migrated from rt.perl.org#75230 (status was 'resolved')

Searchable as RT75230$

@p6rt
Copy link
Author

p6rt commented May 20, 2010

From @masak

<diakopter> rakudo​: say 1 if 2 if 3 { say 3 }
<p6eval> rakudo e6863e​: OUTPUT«1␤3␤»
<jnthn> o_O
<diakopter> o!O
<diakopter> rakudo​: say 1 if 0 if 1 { say 3 } # masak
<p6eval> rakudo e6863e​: OUTPUT«3␤»
* masak submits rakudobug

Judging from the outputs above, it seems like Rakudo hallucinates a
semicolon, creating 'say 1 if 2; if 3 { say 3 }' and 'say 1 if 0; if 3
{ say 3 }', respectively.

This currently seems to be a parsing bug in STD also.

<diakopter> std​: say 1 if 2 if 3 { say 3 }
<p6eval> std 30732​: OUTPUT«ok 00​:01 111m␤»
<masak> o.O
<jnthn> Well, at least we're consistent.
<jnthn> (with STD)
<jnthn> :-)

@p6rt
Copy link
Author

p6rt commented Aug 18, 2010

@coke - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Thu May 20 15​:50​:01 2010, masak wrote​:

This currently seems to be a parsing bug in STD also.

FYI, now STD DTRT​:

14​:14 < diakopter> std​: say 1 if 2 if 3 { say 3 }
14​:14 <+p6eval> std f179a1b​: OUTPUT«Use of uninitialized value $x in
pattern match (m//) at
  STD.pm line 66577.␤Use of uninitialized value $x in
concatenation (.) or
  string at STD.pm line 66616.␤===SORRY!===␤Missing
semicolon at
  /tmp/2yh3PPJvek line 1​:␤------> say 1 if 2⏏[31…

@p6rt
Copy link
Author

p6rt commented Feb 23, 2014

From @coke

On Tue May 29 12​:15​:49 2012, diakopter wrote​:

On Thu May 20 15​:50​:01 2010, masak wrote​:

This currently seems to be a parsing bug in STD also.

FYI, now STD DTRT​:

14​:14 < diakopter> std​: say 1 if 2 if 3 { say 3 }
14​:14 <+p6eval> std f179a1b​: OUTPUT«Use of uninitialized value $x in
pattern match (m//) at
STD.pm line 66577.␤Use of uninitialized value $x in
concatenation (.) or
string at STD.pm line 66616.␤===SORRY!===␤Missing
semicolon at
/tmp/2yh3PPJvek line 1​:␤------> say 1 if 2⏏[31…

STD changed for the better​:

20​:17 < [Coke]> std​: say 1 if 2 if 3 { say 3 }
20​:17 <+camelia> std 09dda5b​: OUTPUT«===SORRY!===␤Missing semicolon at
  /tmp/Ht45Fl9DU1 line 1​:␤------> say 1 if 2⏏ if 3 { say 3
  }␤Parse failed␤FAILED 00​:01 123m␤»

Rakudo is correctly failing.

20​:18 < [Coke]> m​: say 1 if 2 if 3 { say 3 }
20​:18 <+camelia> rakudo-moar b2b333​: OUTPUT«===SORRY!=== Error while compiling
  /tmp/EjEL_Q5O1j␤Confused␤at /tmp/EjEL_Q5O1j​:1␤------> say 1 if
  2 ⏏if 3 { say 3 }␤ expecting any of​:␤ postfix␤»

The error is not the same as STD's, but I think it's good enough - closable with tests.
--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jul 20, 2014

From @peschwa

On Sat Feb 22 17​:20​:15 2014, coke wrote​:

On Tue May 29 12​:15​:49 2012, diakopter wrote​:

On Thu May 20 15​:50​:01 2010, masak wrote​:

This currently seems to be a parsing bug in STD also.

FYI, now STD DTRT​:

14​:14 < diakopter> std​: say 1 if 2 if 3 { say 3 }
14​:14 <+p6eval> std f179a1b​: OUTPUT«Use of uninitialized value $x in
pattern match (m//) at
STD.pm line 66577.␤Use of uninitialized value $x in
concatenation (.) or
string at STD.pm line 66616.␤===SORRY!===␤Missing
semicolon at
/tmp/2yh3PPJvek line 1​:␤------> say 1 if 2⏏[31…

STD changed for the better​:

20​:17 < [Coke]> std​: say 1 if 2 if 3 { say 3 }
20​:17 <+camelia> std 09dda5b​: OUTPUT«===SORRY!===␤Missing semicolon at
/tmp/Ht45Fl9DU1 line 1​:␤------> say 1 if 2⏏ if 3 {
say 3
}␤Parse failed␤FAILED 00​:01 123m␤»

Rakudo is correctly failing.

20​:18 < [Coke]> m​: say 1 if 2 if 3 { say 3 }
20​:18 <+camelia> rakudo-moar b2b333​: OUTPUT«===SORRY!=== Error while
compiling
/tmp/EjEL_Q5O1j␤Confused␤at /tmp/EjEL_Q5O1j​:1␤------>
say 1 if
2 ⏏if 3 { say 3 }␤ expecting any of​:␤
postfix␤»

The error is not the same as STD's, but I think it's good enough -
closable with tests.

Added a test to roast in commit feeea52 as per the example above.

@p6rt
Copy link
Author

p6rt commented Jul 20, 2014

From @peschwa

On Sun Jul 20 01​:12​:18 2014, peschwa@​gmail.com wrote​:

On Sat Feb 22 17​:20​:15 2014, coke wrote​:

On Tue May 29 12​:15​:49 2012, diakopter wrote​:

On Thu May 20 15​:50​:01 2010, masak wrote​:

This currently seems to be a parsing bug in STD also.

FYI, now STD DTRT​:

14​:14 < diakopter> std​: say 1 if 2 if 3 { say 3 }
14​:14 <+p6eval> std f179a1b​: OUTPUT«Use of uninitialized value $x in
pattern match (m//) at
STD.pm line 66577.␤Use of uninitialized value $x in
concatenation (.) or
string at STD.pm line 66616.␤===SORRY!===␤Missing
semicolon at
/tmp/2yh3PPJvek line 1​:␤------> say 1 if 2⏏[31…

STD changed for the better​:

20​:17 < [Coke]> std​: say 1 if 2 if 3 { say 3 }
20​:17 <+camelia> std 09dda5b​: OUTPUT«===SORRY!===␤Missing semicolon at
/tmp/Ht45Fl9DU1 line 1​:␤------> say 1 if 2⏏ if 3 {
say 3
}␤Parse failed␤FAILED 00​:01 123m␤»

Rakudo is correctly failing.

20​:18 < [Coke]> m​: say 1 if 2 if 3 { say 3 }
20​:18 <+camelia> rakudo-moar b2b333​: OUTPUT«===SORRY!=== Error while
compiling
/tmp/EjEL_Q5O1j␤Confused␤at /tmp/EjEL_Q5O1j​:1␤------>
say 1 if
2 ⏏if 3 { say 3 }␤ expecting any of​:␤
postfix␤»

The error is not the same as STD's, but I think it's good enough -
closable with tests.

Added a test to roast in commit feeea52 as per the example above.

To add to that​: [0] makes the .reason of the thrown X​::Syntax​::Confused match the one that STD gives. Spectest looks clean, but I'm not sure if there might be untested cases where the message could be misleading.

[0] rakudo/rakudo#291

@p6rt
Copy link
Author

p6rt commented Jul 20, 2014

From @FROGGS

PR merged​: rakudo/rakudo@9a9f357fea
Test got adjusted​: Raku/roast@6811e5268e
psch++

@p6rt
Copy link
Author

p6rt commented Jul 20, 2014

@FROGGS - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant