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

fix(frontend): crashes on fn ptr #759

Merged
merged 1 commit into from
Jul 10, 2024
Merged

fix(frontend): crashes on fn ptr #759

merged 1 commit into from
Jul 10, 2024

Conversation

W95Psp
Copy link
Collaborator

@W95Psp W95Psp commented Jul 10, 2024

This commit fixes the issue #757: the frontend was assuming functions expressions to be of a very specific shape. This commit fixes that.

This commit fixes the issue #757: the frontend was assuming functions
expressions to be of a very specific shape. This commit fixes that.
@W95Psp W95Psp linked an issue Jul 10, 2024 that may be closed by this pull request
Copy link
Member

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

It looks like the following two functions get translated very differently. Is that on purpose?

fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 {
    f(arg) + f(arg)
}

fn do_again<F>(f: F, arg: i32) -> i32
where
    F: Fn(i32) -> i32,
{
    f(arg) + f(arg)
}
let do_again
      (#v_F: Type0)
      (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: Core.Ops.Function.t_Fn v_F i32)
      (f: v_F)
      (arg: i32)
    : i32 =
  (Core.Ops.Function.f_call #v_F #i32 f (arg <: i32) <: i32) +!
  (Core.Ops.Function.f_call #v_F #i32 f (arg <: i32) <: i32)

let do_twice (f: (i32 -> i32)) (arg: i32) : i32 = f arg +! f arg

frontend/exporter/src/types/copied.rs Show resolved Hide resolved
@W95Psp
Copy link
Collaborator Author

W95Psp commented Jul 10, 2024

Yes, higher-order functions are a bit problematic, that's related to what @paulmure says in #549 (comment)

@W95Psp W95Psp added this pull request to the merge queue Jul 10, 2024
Merged via the queue into main with commit 87a5376 Jul 10, 2024
13 checks passed
@W95Psp W95Psp deleted the fix-757 branch July 10, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Frontend: panic on function item types.
2 participants