Skip Menu |
Report information
Id: 132081
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: bri [at] abrij.org
Cc:
AdminCc:

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



Subject: [LTA] Wrong exception type on bad attribute default values
Download (untitled) / with headers
text/plain 618b
$ perl6 -e 'my Int $a is default("foo");' ===SORRY!=== Error while compiling -e Default value 'foo' will never bind to a parameter of type Int at -e:1 ------> my Int $a is default("foo")⏏; expecting any of: constraint $ perl6 -e 'class A { has Int $.a is default("foo"); }' ===SORRY!=== Error while compiling -e Type check failed in assignment to $!a; expected Int but got Str ("foo") at -e:1 An attribute should probably throw X::Parameter::Default::TypeCheck, like the simple variable does, rather than X::TypeCheck::Assignment+{X::Comp} I'll be adding fudged tests to S02-names/is_default for this.
Download (untitled) / with headers
text/plain 952b
On Wed, 13 Sep 2017 18:21:56 -0700, bri@abrij.org wrote: Show quoted text
> $ perl6 -e 'my Int $a is default("foo");' > ===SORRY!=== Error while compiling -e > Default value 'foo' will never bind to a parameter of type Int > at -e:1 > ------> my Int $a is default("foo")⏏; > expecting any of: > constraint > $ perl6 -e 'class A { has Int $.a is default("foo"); }' > ===SORRY!=== Error while compiling -e > Type check failed in assignment to $!a; expected Int but got Str > ("foo") > at -e:1 > > An attribute should probably throw X::Parameter::Default::TypeCheck, > like the > simple variable does, rather than X::TypeCheck::Assignment+{X::Comp} > > I'll be adding fudged tests to S02-names/is_default for this.
The error message is also mentioned in RT#126296 as a side issue. Also in another ticket I cannot find at the moment, where it is suggested that neither of them are a parameter, so maybe we need new X's for each of variable and attribute.


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