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

Single code path for type checking on a parameter in a built-in sub or method #256

Closed
masak opened this issue Sep 16, 2017 · 0 comments
Closed

Comments

@masak
Copy link
Owner

masak commented Sep 16, 2017

We do oodles of these right now in Builtins.pm:

            die X::TypeCheck.new(:operation<->, :got($lhs), :expected(_007::Object))
                unless $lhs ~~ _007::Object && $lhs.isa("Int");

We could extract that into an internal API so we can do

assertType(:value($lhs), :type<Int>, :operation<->);

instead. Could also consider whether it'd be a useful primitive to provide in 007 itself, given that core 007 doesn't have typed variables and parameters.

@masak masak mentioned this issue May 26, 2018
masak pushed a commit that referenced this issue Jul 14, 2018
Closes #256.

Didn't go so far as to expose it as a 007 primitive. But we can easily
do that at the first use case.
masak pushed a commit that referenced this issue Dec 1, 2018
According to a throwaway comment in #256.

This built-in might not be long-lived, the comment at
#417 (comment)
suggests it might be better to fold this one into `assert`
and make the latter a built-in.

Until then, consider `assertType` a stopgap.
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

2 participants