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

hvmc compile on the example program results in Rust compile error #128

Closed
Anatolay opened this issue Apr 25, 2024 · 1 comment
Closed

hvmc compile on the example program results in Rust compile error #128

Anatolay opened this issue Apr 25, 2024 · 1 comment

Comments

@Anatolay
Copy link

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

@tjjfvi
Copy link
Contributor

tjjfvi commented May 2, 2024

fixed by #127

@tjjfvi tjjfvi closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants