Skip to content

Conversation

@MikaelMayer
Copy link
Member

@MikaelMayer MikaelMayer commented Aug 5, 2024

This PR fixes #5642
I added the corresponding test.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@MikaelMayer MikaelMayer closed this Aug 8, 2024
@MikaelMayer MikaelMayer reopened this Aug 8, 2024
@kbuaaaaaa
Copy link
Contributor

kbuaaaaaa commented Aug 14, 2024

Hi! This is Bua from the CI fuzzing project.

Not sure if this is related but the following code produces error only in rust backend.
The error showed up after you fixed the const initialisation.

original.dfy:

trait T0 {
	const f8 : bool
}
class C0 extends T0 {
	constructor (f8 : bool) {
		this.f8 := f8;
	}	
}

method Main() {
	var c0 := new C0(false);
	print c0.f8, "\n";
}

Command:

dafny build original.dfy -t rs

Output:

Dafny program verifier finished with 1 verified, 0 errors
error[E0046]: not all trait items implemented, missing: `f8`
  --> src/original.rs:48:3
   |
23 |       fn f8(&self) -> bool;
   |       --------------------- `f8` from trait
...
48 | /   impl T0
49 | |     for C0 {}
   | |__________^ missing `f8` in implementation

error[E0308]: mismatched types
  --> src/original.rs:35:7
   |
34 |     pub fn f8(&self) -> bool {
   |                         ---- expected `bool` because of return type
35 |       ::dafny_runtime::Object::<_>::from_ref(self)
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Object<C0>`
   |
   = note: expected type `bool`
            found struct `Object<C0>`

Some errors have detailed explanations: E0046, E0308.
For more information about an error, try `rustc --explain E0046`.
error: could not compile `original` (bin "original") due to 2 previous errors
Error while compiling Rust files. Process exited with exit code 101

MikaelMayer added a commit that referenced this pull request Aug 14, 2024
@MikaelMayer
Copy link
Member Author

Hi! This is Bua from the CI fuzzing project.

Not sure if this is related but the following code produces error only in rust backend. The error showed up after you fixed the const initialisation.

original.dfy:

trait T0 {
	const f8 : bool
}
class C0 extends T0 {
	constructor (f8 : bool) {
		this.f8 := f8;
	}	
}

method Main() {
	var c0 := new C0(false);
	print c0.f8, "\n";
}

Command:

dafny build original.dfy -t rs

Output:

Dafny program verifier finished with 1 verified, 0 errors
error[E0046]: not all trait items implemented, missing: `f8`
  --> src/original.rs:48:3
   |
23 |       fn f8(&self) -> bool;
   |       --------------------- `f8` from trait
...
48 | /   impl T0
49 | |     for C0 {}
   | |__________^ missing `f8` in implementation

error[E0308]: mismatched types
  --> src/original.rs:35:7
   |
34 |     pub fn f8(&self) -> bool {
   |                         ---- expected `bool` because of return type
35 |       ::dafny_runtime::Object::<_>::from_ref(self)
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Object<C0>`
   |
   = note: expected type `bool`
            found struct `Object<C0>`

Some errors have detailed explanations: E0046, E0308.
For more information about an error, try `rustc --explain E0046`.
error: could not compile `original` (bin "original") due to 2 previous errors
Error while compiling Rust files. Process exited with exit code 101

This is not related. Constant on traits are not yet supported on the Dafny to Rust code generator

@MikaelMayer MikaelMayer force-pushed the fix-5642-second-const branch from 71a5f8d to a59357b Compare September 4, 2024 17:41
alex-chew
alex-chew previously approved these changes Sep 5, 2024
Copy link
Contributor

@alex-chew alex-chew left a comment

Choose a reason for hiding this comment

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

LGTM

@MikaelMayer MikaelMayer merged commit 798618b into master Sep 6, 2024
@MikaelMayer MikaelMayer deleted the fix-5642-second-const branch September 6, 2024 19:53
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

Successfully merging this pull request may close these issues.

Second assignment to const crashes the Rust compiler

3 participants