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
As discussed with @SeanTAllen on IRC, we have found an instance of a confusing error message related to iso parameters:
use"random"use"time"classClet _v: U8newvalcreate(rand: (Randomiso | None) = None) =>
let rng =
match rand
| let r: Random => r
| None =>
let now = Time.now()
Rand(now._1.u64(), now._2.u64())
end
_v = rng.u8()
This leads to the following error:
Error:
main.pony:10:9: this capture violates capabilities, because the match would need to differentiate by capability at runtime instead of matching on type alone
| let r: Random => r
^
Info:
main.pony:7:36: the match type allows for more than one possibility with the same type as pattern type, but different capabilities. match type: (Random iso! | None val)
new val create(rand: (Random iso | None) = None) =>
^
main.pony:10:9: pattern type: Random ref
| let r: Random => r
^
main.pony:10:16: matching Random iso! with Random ref could violate capabilities: iso! isn't a subcap of ref
| let r: Random => r
^
main.pony:10:16: matching (Random iso! | None val) with Random ref could violate capabilities
| let r: Random => r
The issue is fixed by adding the missing consume:
...
let rng =
matchconsume rand
...
If the rand parameter's type is specified as Random iso^ (i.e. making it ephemeral), the code compiles, either with or without consume.
The text was updated successfully, but these errors were encountered:
Probably the most consistent way to improve this would be to amend the third info message to say:
main.pony:10:16: matching Random iso! with Random ref could violate capabilities: iso! isn't a subcap of ref (did you forget to consume?)
| let r: Random => r
^
That is, just adding a "(did you forget to consume?)" to any error message where we say "[iso|trn]! is not a subtype of [some other cap]".
Hi
As discussed with @SeanTAllen on IRC, we have found an instance of a confusing error message related to
iso
parameters:This leads to the following error:
The issue is fixed by adding the missing
consume
:If the
rand
parameter's type is specified asRandom iso^
(i.e. making it ephemeral), the code compiles, either with or withoutconsume
.The text was updated successfully, but these errors were encountered: