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

rakudo fails to build AST for subset declaration with regex literal #444

Closed
p6rt opened this issue Dec 1, 2008 · 6 comments
Closed

rakudo fails to build AST for subset declaration with regex literal #444

p6rt opened this issue Dec 1, 2008 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 1, 2008

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

Searchable as RT60976$

@p6rt
Copy link
Author

p6rt commented Dec 1, 2008

From rff.rff@gmail.com

The bug is visibile with the following line

subset GenderStr of Str where /^[m|f]$/ ;

for what I can tell the problem is due to the code to manage
type_declarator that only checks if a EXPR is a PAST​::Block.
A regex is recognized as a block but it lacks some of the structure so
I get this error​:

.Method 'push' not found for invocant of class 'Perl6;Grammar'
current instr.​: 'parrot;Perl6;Grammar;Actions;_block5542' pc 141736
(src/gen_actions.pir​:15745)
called from Sub 'parrot;Perl6;Grammar;Actions;_block5532' pc 141655
(src/gen_actions.pir​:15715)
called from Sub 'parrot;Perl6;Grammar;Actions;type_declarator' pc
141016 (src/gen_actions.pir​:15507)
called from Sub 'parrot;Perl6;Grammar;type_declarator' pc 56741
(src/gen_grammar.pir​:15033)
called from Sub 'parrot;Perl6;Grammar;noun' pc 66124 (src/gen_grammar.pir​:18653)
called from Sub 'parrot;Perl6;Grammar;expect_term' pc 60939
(src/gen_grammar.pir​:16680)
called from Sub 'parrot;PGE;OPTable;parse' pc 1979
(compilers/pge/PGE/OPTable.pir​:554)
called from Sub 'parrot;Perl6;Grammar;statement' pc 27186
(src/gen_grammar.pir​:3693)
called from Sub 'parrot;Perl6;Grammar;statementlist' pc 24938
(src/gen_grammar.pir​:2818)
called from Sub 'parrot;Perl6;Grammar;statement_block' pc 22476
(src/gen_grammar.pir​:1847)
called from Sub 'parrot;Perl6;Grammar;TOP' pc 18370 (src/gen_grammar.pir​:229)
called from Sub 'parrot;PCT;HLLCompiler;parse' pc 640
(src/PCT/HLLCompiler.pir​:390)
called from Sub 'parrot;PCT;HLLCompiler;compile' pc 434
(src/PCT/HLLCompiler.pir​:303)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 868
(src/PCT/HLLCompiler.pir​:502)
called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1233
(src/PCT/HLLCompiler.pir​:676)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1412
(src/PCT/HLLCompiler.pir​:765)
called from Sub 'parrot;Perl6;Compiler;main' pc 16408 (perl6.pir​:168)

Wich seem related to line 3025​:
  $past[0].push($param);

where possibly $past[0] is empty.

A simple solution is to check that the value passed actually is a
regex by verifying the .compiler attribute, and then manage it as just
another literal, constructing a block with smart matching.
The tests pass but I feel the "right" solution may be fixing the
Perl6Regex structure, even because similar code to build the subset
type is used in make_anon_subset.
Sadly, it's the first time I dive into the rakudo source and I do not
feel comfortable doing that.

Attached is the patch, and my minimal test suite, which should
probably go into the perl6 spec, which tests the definition of subsets
but not with a regex literal.
All tests pass, and spectest behaves the same as the unpatched version.

@p6rt
Copy link
Author

p6rt commented Dec 1, 2008

From rff.rff@gmail.com

patch2

@p6rt
Copy link
Author

p6rt commented Dec 1, 2008

From @moritz

On Mon Dec 01 13​:52​:45 2008, rff.rff@​gmail.com wrote​:

Attached is the patch, and my minimal test suite, which should
probably go into the perl6 spec, which tests the definition of subsets
but not with a regex literal.

I've added such a test to t/spec/S12-subset/subtypes.t now in (pugs)
r24130. (It not only tests the creation, but also that the type actually

All tests pass, and spectest behaves the same as the unpatched
version.

I can confirm this, and also that it makes the new tests pass. But I'm
not sufficiently deep in the guts to can confirm that it's the right
thing to do.
If pm, particle or jonathan give thumbs up I can apply it.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Dec 1, 2008

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

@p6rt
Copy link
Author

p6rt commented Dec 3, 2008

From @moritz

Applied after review from pmichaud​:

21​:59 < pmichaud> I looked at the patch for 60976, and while it "feels
wrong" I
  couldn't come up with a better answer for now.
21​:59 < pmichaud> it's okay with me if someone applies it.

Tests pass, thanks you very much for your patch.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Dec 3, 2008

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

@p6rt p6rt closed this as completed Dec 3, 2008
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant