-
-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refcap violation via gencap-constrained type parameter. #1328
Comments
I'll do some investigation of this one. |
FYI this works exactly the same way (broken) when using type parameters on a type instead of on a method (when class Foo
var i: USize = 0
fun ref boom() => i = 3
primitive Bla[A: Foo #read]
fun apply(x: A) =>
x.boom()
actor Main
new create(env: Env) =>
let a: Foo val = Foo
env.out.print(a.i.string())
Bla[Foo val](a)
env.out.print(a.i.string()) |
The problem is somewhere in the logic for type params in We need to figure out why the following is seen as true: ast_t* sub = /*(typeparamref (id A) #read x)*/;
ast_t* sup = /*(typeparamref (id A) ref x)*/;
is_subtype(sub, sup, &info, opt); // should be false, but comes back as true I'll look more into this later today. |
The issue is that |
Docs for
This doesn't seem correct in this situation, and we should use |
Unassigning myself for now since I have knowledge-dumped what I have found, and I probably won't have time to work more on this in the next few days. Someone else can feel free to pick up where I left off if they wish, or I will come back to it later in the week. |
I did take a little more of a look at this tonight, and I don't feel confident stepping in with a solution without @sylvanc dropping some type theory guidance on me first. I think the problem may be a bit more general than I first thought - requiring a careful approach to avoid making other mistakes in the solution. |
The solution is to change the |
I've encountered another instance of this bug. interface I
fun ref foo() => None
class C
fun ref foo() => None
actor Main
new create(env: Env) =>
foo[C tag](C)
fun foo[A: I #any](a: A) =>
a.foo() Here, |
To give an update on this, the fix that was discussed earlier seemed not to do the trick. My plan is to check in with @sylvanc next wednesday to discuss the issue in depth and find the appropriate approach. However, I've unassigned myself in case anyone else wants to take a shot between now and then. |
This fixes an assertion failure when chaining an #any receiver. Because of other bugs in the implementation (namely ponylang#1328), non-tag methods can currently be called on an #any receiver. Another assertion has been added to prevent this case silently pass.
This fixes an assertion failure when chaining an #any receiver. Because of other bugs in the implementation (namely ponylang#1328), non-tag methods can currently be called on an #any receiver. Another assertion has been added to prevent this case to silently pass.
This fixes an assertion failure when chaining an #any receiver. Because of other bugs in the implementation (namely #1328), non-tag methods can currently be called on an #any receiver. Another assertion has been added to prevent this case to silently pass.
We got another report of this in #1549. I'll paste the repro here, so that we have another test case to check the fix against: trait Foo
fun foo()
class Bar is Foo
fun foo() => None
actor Main
fun call_foo[X: Foo #any](x: X) =>
x.foo() // This works, but probably shouldn't work
new create(e: Env) =>
let x : Bar tag = Bar
call_foo[Bar tag](x)
// This fails to type check as expected
// x.foo() |
This compiles fine and prints 0 then 3. The
val
object was indeed modified.The text was updated successfully, but these errors were encountered: