HigherOrderCO/hvm-64

hvmc compile on the example program results in Rust compile error

Closed this issue · 1 comments

Given:
Running example program from the README using latest master (8a9a009)

@add = (<+ a b> (a b))

@sum = (?<(#1 @sumS) a> a)

@sumS = ({2 a b} c)
  & @add ~ (e (d c))
  & @sum ~ (a d)
  & @sum ~ (b e)

@main = a
  & @sum ~ (#24 a)

I get the following error:

error[E0382]: use of moved value: `def_sum`
  --> src/gen.rs:16:79
   |
11 |   let def_sum = Port::new_ref(&host.defs[r#"sum"#]);
   |       ------- move occurs because `def_sum` has type `port::Port`, which does not implement the `Copy` trait
...
14 |   host.get_mut::<HostedDef<Def_main>>(r#"main"#).data.0 = Def_main { def_sum };
   |                                                                      ------- value moved here
15 |   host.get_mut::<HostedDef<Def_sum>>(r#"sum"#).data.0 = Def_sum { def_sumS };
16 |   host.get_mut::<HostedDef<Def_sumS>>(r#"sumS"#).data.0 = Def_sumS { def_add, def_sum };
   |                                                                               ^^^^^^^ value used here after move
   |
help: consider cloning the value if the performance cost is acceptable
   |
14 |   host.get_mut::<HostedDef<Def_main>>(r#"main"#).data.0 = Def_main { def_sum: def_sum.clone() };
   |

Applying the suggested fix resolves the issue and program works correctly

fixed by #127