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

Wrong exception type on bad attribute default values #6512

Open
p6rt opened this issue Sep 14, 2017 · 2 comments
Open

Wrong exception type on bad attribute default values #6512

p6rt opened this issue Sep 14, 2017 · 2 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Sep 14, 2017

Migrated from rt.perl.org#132081 (status was 'new')

Searchable as RT132081$

@p6rt
Copy link
Author

p6rt commented Sep 14, 2017

From @skids

$ 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.

@p6rt
Copy link
Author

p6rt commented Sep 14, 2017

From @skids

On Wed, 13 Sep 2017 18​:21​:56 -0700, bri@​abrij.org wrote​:

$ 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.

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant