-
Notifications
You must be signed in to change notification settings - Fork 65
TAny
should be a proper function type
#571
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
Comments
how did you end up triggering this? can you send a repro? (it's ok if the repro is with eurydice) |
Thanks. It was when I want to experiment if I can add the support for |
Why don't you translate it into an EApp node, even if the head is an EBound? You should be able to provide correct type information for it, which means the rest of the translation should go smoothly. Are you attempting to translate closures? If so, @Nadrieril has some improvements in the pipeline. |
Overall, I'm quite interested in your use-case, so if you could say a little more about what you are trying to achieve, possibly with a complete repro, I might be able to provide more useful suggestions. |
Thanks for your advice! Actually, I'm just trying to understand the codes better rather than working in some specific use case. I think Fn (closure) is a bit harder that it essentially involves deciding the associated types, which I thought is a bit troublesome even in Charon? So, I want to add support for fn to just have a try, which seems to be just a millimeter away that FnOpMove is not supported. And yes, I used EApp, but I just wanted to introduce a unique marker function (app) for it and then remove the marker in the generated C codes. And there are additional difficulties when I want to introduce different types for different apply functions. If the fn type involves generic or even const generics... |
Further, despite the cases, I wanted to implement a function for each stuff with type attached, and I believe have implemented correctly, but was then stopped by the Krml check... I have the use case: fn multiple_ptr(f : fn(&i32, &i32) -> i32) -> i32 {
f(&1,&2)
} So, the translated Low* is the following, as shown in the log:
I guess this perfectly aligns with my intention. But the "checker" log from Krml then shows a strange error of subtype mismatch for "int32_t (a.k.a. int32_t) vs: int32_t* -> int32_t (a.k.a. int32_t* -> int32_t)". I printed out the log, which is strange:
Note that, everything works fine but suddenly in the final line, the error occurs. I guess there is a bug within the Krml checking procedure. |
Two possibilities.
Sometimes, the closure type requires passing an extra "address-of" for the captured state. Could this be what you're experiencing? (I have not debugged this further since I did not work on closures very much.)
Is this normal? [check] annot= int32_t* -> int32_t for e=$$apply$2 @6 @5 @2 -- is an arrow type the result you expect for your application of |
Thanks for spotting 2! Yes, you're right and it works now! |
Great! I assume you'll submit a PR? |
I'll have a try. |
Thanks! Looking forward to it this seems like a generally useful addition |
As the title, the function
analyze_function_type
, inStructs.ml
, currently accepts onlyTArrow
as proper function types. ButTAny
should also be a proper function type? E.g., for Haskell-like codes:undefined x y
should also work.A potential problem happens here that some usage of
analyze_function_type
will need the length of the arguments, butTAny
has no information about the potential application length. Is this a simple problem to fix?The text was updated successfully, but these errors were encountered: