Skip to content

Commit

Permalink
Chopping parameters off the head of closures does not seem to work
Browse files Browse the repository at this point in the history
  • Loading branch information
msprotz committed Sep 10, 2024
1 parent 36ae220 commit 207141e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
10 changes: 1 addition & 9 deletions lib/AstOfLlbc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1262,15 +1262,7 @@ let expression_of_rvalue (env : env) (p : C.rvalue) : K.expr =
let fun_ptr = { C.func = C.FunId (FRegular func); generics } in
let e, _, _ = expression_of_fn_ptr env fun_ptr in
begin
let t, ts = Krml.Helpers.flatten_arrow e.typ in
let rec chop_trait_methods = function
| K.TBuf _ :: _ as ts -> ts
| _ :: ts -> chop_trait_methods ts
| _ -> failwith "impossible"
in
let ts = chop_trait_methods ts in
let t = Krml.Helpers.fold_arrow ts t in
match t with
match e.typ with
| TArrow ((TBuf (TUnit, _) as t_state), t) ->
(* Empty closure block, passed by address...? TBD *)
K.(with_type t (EApp (e, [ with_type t_state (EAddrOf Krml.Helpers.eunit) ])))
Expand Down
7 changes: 7 additions & 0 deletions test/mismatch/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions test/mismatch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "mismatch"
version = "0.1.0"
edition = "2021"

[dependencies]
18 changes: 18 additions & 0 deletions test/mismatch/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pub trait Operations: Clone + Copy {
fn zero() -> Self;
}
pub struct MlKemKeyPairUnpacked<const K: usize, Vector: Operations> {
x: [Vector; K],
}

impl<const K: usize, Vector: Operations> MlKemKeyPairUnpacked<K, Vector> {
#[inline(always)]
pub(crate) fn default() -> Self {
Self {
x: core::array::from_fn(|_| Vector::zero()),
}
}
}

fn main() {
}

0 comments on commit 207141e

Please sign in to comment.