-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add boolean flag to skip argument type checking of builtin functions. #231
Conversation
@@ -833,6 +835,19 @@ impl<B: Backend> TypeChecker<B> { | |||
None => (), | |||
}; | |||
|
|||
// get the ignore_arg_types flag from the function info if it's a builtin | |||
let ignore_arg_types = match self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work for me but I am not sure if this is the correct way to check if a function is builtin.
@@ -392,7 +392,8 @@ impl<B: Backend> TypeChecker<B> { | |||
qualified, | |||
FnInfo { | |||
is_hint: true, | |||
kind: FnKind::BuiltIn(function.sig.clone(), fn_handle), | |||
// todo: is there a case where we want to ignore argument types for hint functions? | |||
kind: FnKind::BuiltIn(function.sig.clone(), fn_handle, false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't immediately decide what to do here since we first convert a hint function to a builtin one. It felt like we would never disable argument type checking for a hint function so I defaulted to false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builtin hints will be deprecated soon. So don't worry bout this.
Good insight!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
@mimoo may want another pass
@@ -392,7 +392,8 @@ impl<B: Backend> TypeChecker<B> { | |||
qualified, | |||
FnInfo { | |||
is_hint: true, | |||
kind: FnKind::BuiltIn(function.sig.clone(), fn_handle), | |||
// todo: is there a case where we want to ignore argument types for hint functions? | |||
kind: FnKind::BuiltIn(function.sig.clone(), fn_handle, false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builtin hints will be deprecated soon. So don't worry bout this.
Good insight!
maybe we should check if this allows us to implement what we wanted to implement on top of that? @varunthakore do you want to try to implement a generic @bufferhe4d if you want to do something similar, a generic |
I currently have an assert_eq that is working with all the types (Field, Bool, arbitrary depth structs and arrays) in the language (using the boolean flag we introduced in this PR). It only checks whether the two argument types matched as you described. Since it requires the flag included here, should I push this functionality to this branch to make it a part of this PR or should I wait until this is merged to open a separate PR? |
can you open a separate PR that targets this branch? Even if it doesn't work because this branch is on a remote repo, can you still open a separate PR? also can you fix the CI issues here? It seems like there's some formatting issues |
I created a draft PR from my generic_assert_eq here: bufferhe4d#2 The CI should be fixed now. |
Attempts to resolve #228.
Here is my approach:
As suggested in #228 I first introduced a new flag for the
FnKind::Builtin
calledignore_arg_types
:https://github.com/bufferhe4d/noname/blob/b243dce51ddbb96babf627fd3c1a8b5266d261ab/src/imports.rs#L78
Propagated this to all the occurrences of this. Then implemented the actual skip in the type checker.