Navigation Menu

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

Can't use a where clause on an attribute without surrounding name and where clause in parentheses in Rakudo #1854

Closed
p6rt opened this issue Jun 18, 2010 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Jun 18, 2010

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

Searchable as RT75858$

@p6rt
Copy link
Author

p6rt commented Jun 18, 2010

From @masak

<masak> std​: class A { has Int $.color where 1|2; }
<p6eval> std 31360​: OUTPUT«�===SORRY!�===�␤Two terms in a row at
/tmp/vVVvjpuKJP line 1​:␤------> class A { has Int $.color ⏏where 1|2;
} [...] Parse failed␤FAILED 00​:01
<TimToady> hmm
<masak> and here I was going to submit a rakudobug...
<masak> rakudo​: class A { has Int $.color where 1|2; }
<p6eval> rakudo d2add4​: OUTPUT«===SORRY!===␤Unable to parse blockoid,
couldn't find final '}' at line 11␤»
<masak> alpha​: class A { has Int $.color where 1|2; }
<p6eval> alpha 30e0ed​: ( no output )
* masak likes alpha's response the best
<masak> TimToady​: did that 'hmm' mean 'STD.pm6 should parse this --
wonder why it doesn't?' ?
<TimToady> yes
* masak submits rakudobug
* jnthn also surprised
<masak> rakudo​: class A { has $.x where 1 }
<p6eval> rakudo d2add4​: OUTPUT«===SORRY!===␤Unable to parse blockoid,
couldn't find final '}' at line 11␤»
<TimToady> std​: class A { has (Int $.color where 1|2); }
<p6eval> std 31360​: OUTPUT«ok 00​:01 112m␤»
<jnthn> rakudo​: class A { has ($.x where 1) }
<p6eval> rakudo d2add4​: ( no output )
<jnthn> ah
<jnthn> Yeah, only works if we parse a siggy.
<masak> I'd expect it to work without the parens, though.
<jnthn> Same
<jnthn> Now sure how much of a pain it'll be.
<jnthn> Hopefully almost none.

@p6rt
Copy link
Author

p6rt commented Oct 21, 2011

From @coke

No change in year+.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 21, 2011

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

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Thu Oct 20 17​:46​:28 2011, coke wrote​:

No change in year+.

Now outputs​:

14​:40 < diakopter> rakudo​: class A { has $c where 1; }
14​:40 <+p6eval> rakudo 223419​: OUTPUT«===SORRY!===␤Contextual
%*PARAM_INFO not found␤»

@p6rt
Copy link
Author

p6rt commented Oct 16, 2014

From @usev6

All of the above parses now (on Moar, Parrot and JVM)​:

$ perl6 -e 'class A { has ($.x where 1) }; say "alive"'
alive

$ perl6 -e 'class A { has $.x where 1 }; say "alive"'
alive

$ perl6-m -e 'class A { has $x where 1; }; say "alive"'
alive

$ perl6 -e 'class A { has Int $.color where 1|2; }; say "alive"'
alive

STD also agrees​:

$ viv -c -e 'class A { has Int $.color where 1|2; }'
syntax OK

But before adding tests I wonder whether the where clause has any effect. Shouldn't the following complain that $.color is restricted to values 1 and 2?

$ perl6 -e 'class A { has Int $.color where 1|2 }; my $a = A.new( color => 3 ); say $a;'
A.new(color => 3)

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 16, 2014

From @usev6

All of the above parses now (on Moar, Parrot and JVM)​:

$ perl6 -e 'class A { has ($.x where 1) }; say "alive"'
alive

$ perl6 -e 'class A { has $.x where 1 }; say "alive"'
alive

$ perl6-m -e 'class A { has $x where 1; }; say "alive"'
alive

$ perl6 -e 'class A { has Int $.color where 1|2; }; say "alive"'
alive

STD also agrees​:

$ viv -c -e 'class A { has Int $.color where 1|2; }'
syntax OK

But before adding tests I wonder whether the where clause has any effect. Shouldn't the following complain that $.color is restricted to values 1 and 2?

$ perl6 -e 'class A { has Int $.color where 1|2 }; my $a = A.new( color => 3 ); say $a;'
A.new(color => 3)

@p6rt
Copy link
Author

p6rt commented Oct 20, 2014

From @usev6

On Thu Oct 16 02​:51​:19 2014, bartolin@​gmx.de wrote​:

But before adding tests I wonder whether the where clause has any
effect. Shouldn't the following complain that $.color is restricted to
values 1 and 2?

$ perl6 -e 'class A { has Int $.color where 1|2 }; my $a = A.new(
color => 3 ); say $a;'
A.new(color => 3)

I found ticket 122109 (https://rt-archive.perl.org/perl6/Ticket/Display.html?id=122109) which is a about where clauses on attributes NYI.

So I added a test for this ticket to S12-class/attributes.t with the following commit​: Raku/roast@cc6dfe8bd8. I'm closing this ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 20, 2014

From @usev6

On Thu Oct 16 02​:51​:19 2014, bartolin@​gmx.de wrote​:

But before adding tests I wonder whether the where clause has any
effect. Shouldn't the following complain that $.color is restricted to
values 1 and 2?

$ perl6 -e 'class A { has Int $.color where 1|2 }; my $a = A.new(
color => 3 ); say $a;'
A.new(color => 3)

I found ticket 122109 (https://rt-archive.perl.org/perl6/Ticket/Display.html?id=122109) which is a about where clauses on attributes NYI.

So I added a test for this ticket to S12-class/attributes.t with the following commit​: Raku/roast@cc6dfe8bd8. I'm closing this ticket now.

@p6rt p6rt closed this as completed Oct 20, 2014
@p6rt
Copy link
Author

p6rt commented Oct 20, 2014

@usev6 - 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