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

Failure has no type check in constructor which leads to LTA errors #2947

Closed
p6rt opened this issue Oct 23, 2012 · 8 comments
Closed

Failure has no type check in constructor which leads to LTA errors #2947

p6rt opened this issue Oct 23, 2012 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Oct 23, 2012

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

Searchable as RT115436$

@p6rt
Copy link
Author

p6rt commented Oct 23, 2012

From @bbkr

Rakudo 2012.09

$ perl6 -e 'Failure.new("foo").();'
No such method 'throw' for invocant of type 'Str'
  in method <anon> at src/gen/CORE.setting​:9914
  in at src/gen/Metamodel.pm​:2380
  in any find_method_fallback at src/gen/Metamodel.pm​:2368
  in any find_method at src/gen/Metamodel.pm​:922
  in at src/gen/BOOTSTRAP.pm​:827
  in any at src/gen/BOOTSTRAP.pm​:811
  in block at -e​:1

Those LTA errors can be avoided by adding Exception (or some kind of "throwable" if there is any) type check to Failure constructor.

@p6rt
Copy link
Author

p6rt commented Mar 16, 2015

From @usev6

Locally I simply added a type constraint to method new for class Failure​:

$ diff src/core/Failure.pm Failure.pm.orig
5c5
< method new(Exception $exception) { self.bless(​:$exception) }


method new\($exception\) \{ self\.bless\(&#8203;:$exception\) \}

With that change the error message became​:

$ perl6 -e 'Failure.new("foo").();'
Type check failed in binding $exception; expected 'Exception' but got 'Str'
  in method new at src/gen/m-CORE.setting​:15706
  in block <unit> at -e​:1

Would that be good enough?

1 similar comment
@p6rt
Copy link
Author

p6rt commented Mar 16, 2015

From @usev6

Locally I simply added a type constraint to method new for class Failure​:

$ diff src/core/Failure.pm Failure.pm.orig
5c5
< method new(Exception $exception) { self.bless(​:$exception) }


method new\($exception\) \{ self\.bless\(&#8203;:$exception\) \}

With that change the error message became​:

$ perl6 -e 'Failure.new("foo").();'
Type check failed in binding $exception; expected 'Exception' but got 'Str'
  in method new at src/gen/m-CORE.setting​:15706
  in block <unit> at -e​:1

Would that be good enough?

@p6rt
Copy link
Author

p6rt commented Mar 16, 2015

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

@p6rt
Copy link
Author

p6rt commented Jun 20, 2015

From @usev6

I added a test to S04-exceptions/fail.t with commit Raku/roast@4366d917a5 and created a pull request for Rakudo​: rakudo/rakudo#442

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jun 20, 2015

From @usev6

I added a test to S04-exceptions/fail.t with commit Raku/roast@4366d917a5 and created a pull request for Rakudo​: rakudo/rakudo#442

@p6rt
Copy link
Author

p6rt commented Jun 20, 2015

From @usev6

The test passes now. I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Jun 20, 2015

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

@p6rt p6rt closed this as completed Jun 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant