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

Nil type constraint yields bad error message #4542

Closed
p6rt opened this issue Sep 17, 2015 · 4 comments
Closed

Nil type constraint yields bad error message #4542

p6rt opened this issue Sep 17, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Sep 17, 2015

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

Searchable as RT126091$

@p6rt
Copy link
Author

p6rt commented Sep 17, 2015

From zefram@fysh.org

$ perl6 -e 'my Nil $a = 3'
Type check failed in assignment to '$a'; expected 'Any' but got 'Int'
  in block <unit> at -e​:1

It is correct to get an error of this general type, but the message
is incorrect in identifying the expected type. The message appears
nonsensical, because an Int would satisfy an Any constraint. A similar
faulty message can be produced in other coercion situations too​:

$ perl6 -e 'sub aa (Nil $a) { }; my $b = 3; aa($b)'
Type check failed in binding $a; expected 'Any' but got 'Int'
  in sub aa at -e​:1
  in block <unit> at -e​:1

I have some suspicion that this faulty message is a result of the
intentional but somewhat surprising behaviour of assigning Nil to
a scalar​:

$ perl6 -e 'my $a = Nil; say $a.perl'
Any

-zefram

@p6rt
Copy link
Author

p6rt commented Nov 12, 2015

From @usev6

The error messages correctly mention Nil now​:

$ perl6 -e 'my Nil $a = 3'
Type check failed in assignment to $a; expected Nil but got Int
  in block <unit> at -e​:1

$ perl6 -e 'sub aa (Nil $a) { }; my $b = 3; aa($b)'
Type check failed in binding $a; expected Nil but got Int
  in sub aa at -e​:1
  in block <unit> at -e​:1

I added two tests to S32-exceptions/misc.t with commit Raku/roast@3fe83cf8dc

I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Nov 12, 2015

From @usev6

The error messages correctly mention Nil now​:

$ perl6 -e 'my Nil $a = 3'
Type check failed in assignment to $a; expected Nil but got Int
  in block <unit> at -e​:1

$ perl6 -e 'sub aa (Nil $a) { }; my $b = 3; aa($b)'
Type check failed in binding $a; expected Nil but got Int
  in sub aa at -e​:1
  in block <unit> at -e​:1

I added two tests to S32-exceptions/misc.t with commit Raku/roast@3fe83cf8dc

I'm closing this ticket as 'resolved'.

@p6rt p6rt closed this as completed Nov 12, 2015
@p6rt
Copy link
Author

p6rt commented Nov 12, 2015

@usev6 - Status changed from 'new' 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