You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Repro {
trait Foo {}
classBar extends Foo {
constructor() {}
}
datatype Option<+T> = Some(value: T) | None
datatype D = D(Option<Foo>)
methodMain() {
var b: Bar :=newBar();
var d :=D(Some(b));
}
}
Command to run and resulting output
% dafny run -t:java src/Scratch.dfy
Dafny program verifier finished with 1 verified, 0 errors
/Users/salkeldr/Documents/GitHub/libraries/src/Scratch-java/Repro_Compile/__default.java:17: error: incompatible types: Option<Bar> cannot be converted to Option<Foo>
_1_d = Repro_Compile.D.create(Repro_Compile.Option.<Bar>create_Some(_0_b));
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Error while compiling Java files. Process exited with exit code 1
What happened?
Root case is that the D data constructor creation method D.create has the following signature:
Dafny version
master, not yet released (edab6cc)
Code to produce this issue
Command to run and resulting output
What happened?
Root case is that the
D
data constructor creation methodD.create
has the following signature:But given
Option
's type parameter is covariant, it should be:Or perhaps the intent was to insert an explicit unchecked
(Option<Foo>)
cast before passing theOption<Bar>
value to the constructor.This works correctly if the data constructor parameter is a
seq<T>
instead, which is also implicitly covariant.@RustanLeino This looks like a missing case from #3072?
What type of operating system are you experiencing the problem on?
Mac
The text was updated successfully, but these errors were encountered: