Skip to content
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

Foo iso is outside constraint Foo iso | Bar val #1807

Closed
plietar opened this issue Apr 5, 2017 · 5 comments
Closed

Foo iso is outside constraint Foo iso | Bar val #1807

plietar opened this issue Apr 5, 2017 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@plietar
Copy link
Contributor

plietar commented Apr 5, 2017

interface Foo
interface Bar
class Baz
  fun foo[X: (Foo iso | Bar val)]() =>
    None

  fun bar() =>
    foo[Foo iso]()
Error:
main.pony:9:5: type argument is outside its constraint
    foo[Foo iso]()
    ^
    Info:
    main.pony:9:9: argument: Foo iso
        foo[Foo iso]()
            ^
    main.pony:5:11: constraint: Bar val
      fun foo[X: (Foo iso | Bar val)]() =>
              ^
    main.pony:9:9: Foo iso is not in constraint Bar val: iso is not in constraint val
        foo[Foo iso]()

https://is.gd/5upkoo

This error occurs with both iso and trn. It works with other capabilities.
I'm not completely sure whether this should be allowed or not, but I'd be inclined to say yes.

@SeanTAllen SeanTAllen added needs discussion during sync triggers release Major issue that when fixed, results in an "emergency" release labels Apr 5, 2017
@sylvanc
Copy link
Contributor

sylvanc commented Apr 26, 2017

This is happening because union flattening is reducing the constraint to Bar val, which is of course wrong.

@jemc
Copy link
Member

jemc commented Apr 26, 2017

This can be solved by: during union flattening, check the current frame and see if we are in a constraint before invoking is_subtype - if we are we should invoke is_subtype_constraint instead.

@jemc
Copy link
Member

jemc commented Apr 26, 2017

Careful caveat though - we don't want to use is_subtype_constraint when the union is within the type arguments of a constraint type. For example, in [A: Array[(B | C)], we'd use is_subtype as normal - this is important to add a test case for when fixed.

@SeanTAllen
Copy link
Member

@plietar says he has a non-flattening removing fix that can address this specifically.

@SeanTAllen SeanTAllen added bug Something isn't working and removed bug: 4 - in progress labels May 12, 2020
@SeanTAllen SeanTAllen added the help wanted Extra attention is needed label Apr 27, 2022
@SeanTAllen SeanTAllen removed the triggers release Major issue that when fixed, results in an "emergency" release label Oct 6, 2023
@SeanTAllen
Copy link
Member

At some point, this was fixed.

@ponylang-main ponylang-main added discuss during sync Should be discussed during an upcoming sync and removed discuss during sync Should be discussed during an upcoming sync labels Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants