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
In Sway similarly to Rust, one can define function over a generic type which can be further constrained by
a trait. An example can be found in the following snippet:
Here bar, returns a generic Option T where T should implement MyTrait. When we force the result to
monomorphize with a type ascription, the compiler should check if the concrete type satisfies the trait
bounds. However, this doesn't happen therefore the example below successfully compiles.
fnmain(){
letx:Option<u32> =bar();
}
Note, however, that the following, seemingly equivalent snippet, will be rejected by the compiler:
fnmain(){
letx=bar::<Option<u32>>();
}
The text was updated successfully, but these errors were encountered:
We still do have a separate bug in this example. The type mentioned in the trait not implemented error is not always fully correct. This will be solved as a separate issue #6496.
CS-FSSA-014
In Sway similarly to Rust, one can define function over a generic type which can be further constrained by
a trait. An example can be found in the following snippet:
Here bar, returns a generic Option T where T should implement MyTrait. When we force the result to
monomorphize with a type ascription, the compiler should check if the concrete type satisfies the trait
bounds. However, this doesn't happen therefore the example below successfully compiles.
Note, however, that the following, seemingly equivalent snippet, will be rejected by the compiler:
The text was updated successfully, but these errors were encountered: