Skip Menu |
Report information
Id: 77350
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: moritz <moritz.lenz+perl [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Calling a token 'any' calls for trouble
Date: Sat, 21 Aug 2010 22:43:38 +0200
To: rakudobug [...] perl.org
From: Moritz Lenz <moritz [...] faui2k3.org>
Download (untitled) / with headers
text/plain 738b
22:39 < moritz_> rakudo: grammar A { token TOP { <any> }; token any { 'foo' | 'bar' } }; say A.parse('foo') 22:39 <+p6eval> rakudo d1015f: OUTPUT«Too many positional parameters passed; got 2 but expected 1␤ in 'Any::any' at line 1361:CORE.setting␤ in 'A::any' at line 22:/tmp/PUiWn8O0Uy␤ in 'A::TOP' at line 22:/tmp/PUiWn8O0Uy␤ in 'Grammar::parse' at line 5864:CORE.setting␤ in main program body at line 22:39 <+p6eval> ..22:/tmp/PUiWn8O0Uy␤» 22:40 < moritz_> that's a bug, right? 22:40 < pmichaud> well, the grammar is overriding the .any method 22:41 < moritz_> pmichaud: but it's not the overridden .any method that is called, right? 22:41 < pmichaud> moritz_: I'm still trying to figure out what's happening there.
No change in the past year. -- Will "Coke" Coleda
Download (untitled) / with headers
text/plain 288b
The problem is that the $*ACTIONS contextual is set to a type object (used to be Any, now Mu), so $*ACTIONS.any existed, but caused an error. commit 0973612366de17d6eab26e975663e63170e5d1d5 eased some of the pain by switching it from Any to Mu, but the underlying problem is still there.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 586b
On Thu Oct 18 02:13:15 2012, moritz wrote: Show quoted text
> The problem is that the $*ACTIONS contextual is set to a type object > (used to be Any, now Mu), so $*ACTIONS.any existed, but caused an error. > > commit 0973612366de17d6eab26e975663e63170e5d1d5 eased some of the pain > by switching it from Any to Mu, but the underlying problem is still there.
00:11 <Mouq> r: grammar A { token TOP { <any> }; token any { 'foo' | 'bar' } }; say A.parse('foo') 00:11 <camelia> rakudo-parrot 79167a, rakudo-jvm 79167a, rakudo-moar 79167a: OUTPUT«「foo」␤ any => 「foo」␤␤» Closeable with tests
Subject: Re: [perl #77350] Calling a token 'any' calls for trouble
To: perl6-bugs-followup [...] perl.org
Date: Mon, 14 Apr 2014 13:00:33 +0200
From: Moritz Lenz <moritz [...] faui2k3.org>
Download (untitled) / with headers
text/plain 1.1k
On 04/14/2014 06:11 AM, Alexander Moquin via RT wrote: Show quoted text
> On Thu Oct 18 02:13:15 2012, moritz wrote:
>> The problem is that the $*ACTIONS contextual is set to a type object >> (used to be Any, now Mu), so $*ACTIONS.any existed, but caused an error. >> >> commit 0973612366de17d6eab26e975663e63170e5d1d5 eased some of the pain >> by switching it from Any to Mu, but the underlying problem is still there.
> > 00:11 <Mouq> r: grammar A { token TOP { <any> }; token any { 'foo' | 'bar' } }; say A.parse('foo') > 00:11 <camelia> rakudo-parrot 79167a, rakudo-jvm 79167a, rakudo-moar 79167a: OUTPUT«「foo」␤ any => 「foo」␤␤» > > Closeable with tests
The problem can still be reproduced with method names from class Mu, for example 'so': <moritz> m: grammar A { token TOP { <so> }; token so { 'foo' | 'bar' } }; say A.parse('foo') <camelia> rakudo-moar 07dcb2: OUTPUT«Too many positional parameters passed; got 2 but expected 1␤ in method so at src/gen/m-CORE.setting:834␤ in any !reduce at gen/moar/stage2/QRegex.nqp:759␤ in any !cursor_pass at gen/moar/stage2/QRegex.nqp:721␤ in regex so at /tmp/4Fzij7cVZH:1…»
Download (untitled) / with headers
text/plain 295b
I added a test in S05-grammar/inheritance.t but I'm unsure if this is a valid bug. If the default actions dispatch off the Mu type object then this is expected behavior. Maybe they can be sidestepped as a special case for grammar actions? Or at least a better error message could be spit out.
Download (untitled) / with headers
text/plain 217b
The correct solution would be to track the presence or absence of an action class by an out-of-bounds mechanism, like a separate variable. I just don't know how to do that without making parsing significantly slower.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org