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
Dynamic casting (failable casting as?, and force casting as!) an optional value (potentially type-erased to an existential) to a non-optional type currently fails (e.g. failable casting results in nil).
Expected Behavior
I expected (but perhaps shouldn't have) that an optional value being casted into a subtype it conforms to would unwrap it. I'm really not sure if this is a bug or if it's expected though
Steps To Reproduce
I've made a repro contract/transactions to demonstrate
I guess that makes sense. For example, Swift also supports unwrapping using casting:
lethello:String???="hello"letsomething:Any= hello
something as!String// "hello" of type `String`
However, casting to Any does not:
something as!Any// Optional(Optional(Optional("hello"))) of type `String???`
Then again, the behaviour does not seem to be about existential types, because those are also unwrapped:
protocolI{}structS:I{}lethello:S????=S()letsomething:Any= hello
something as!anyI// S() of type `S`, not `Optional(Optional(Optional(S())))` of type `S???`
Current Behavior
Dynamic casting (failable casting
as?
, and force castingas!
) an optional value (potentially type-erased to an existential) to a non-optional type currently fails (e.g. failable casting results innil
).Expected Behavior
I expected (but perhaps shouldn't have) that an optional value being casted into a subtype it conforms to would unwrap it. I'm really not sure if this is a bug or if it's expected though
Steps To Reproduce
I've made a repro contract/transactions to demonstrate
https://github.com/austinkline/cadence-burner-bug
Environment
The text was updated successfully, but these errors were encountered: