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

Parametric polymorphism and array types seem to be broken #236

Closed
TobiasWrigstad opened this issue Oct 2, 2015 · 8 comments
Closed

Parametric polymorphism and array types seem to be broken #236

TobiasWrigstad opened this issue Oct 2, 2015 · 8 comments
Assignees

Comments

@TobiasWrigstad
Copy link
Contributor

It seems an additional level of array is added.

class Main
  def main() : void
    ()

passive class Bug<t>
  def here() : Bug<[t]>
    new Bug<[t]>

generates

Type 'Bug<[[t]]>' does not match expected type 'Bug<[t]>'
In expression:
  new Bug<[t]>
In method 'here' of type 'Bug<[t]>'
In class 'Bug<t>'
@EliasC
Copy link
Contributor

EliasC commented Oct 2, 2015

I can look at this while fixing #234!

@EliasC EliasC self-assigned this Oct 2, 2015
@TobiasWrigstad
Copy link
Contributor Author

Thanks!

@albertnetymk
Copy link
Contributor

I am a bit confused. I thought the error message is expected, for we are substituting t with [t] in the new statement, and the return type becomes [[t]] accordingly.

@EliasC
Copy link
Contributor

EliasC commented Oct 3, 2015

Let's make a more concrete example:

class List<t>
  def eachElementAsAnArray() : List<[t]>
    let l = new List<[t]> in
      ... -- some expression that ends in l

Would you agree that this code should compile?

@albertnetymk
Copy link
Contributor

Could you provide complete snippet?

@EliasC
Copy link
Contributor

EliasC commented Oct 3, 2015

passive class Container<t>
  content : t
  def containerWithArray() : Container<[t]>
    let c = new Container<[t]> in {
      c.content = [this.content];
      c
    }

class Main
  def main() : void
    let c1 = new Container<int> in{
      c1.content = 42;
      let c2 = c1.containerWithArray() in
        assertTrue(c2.content[0] == c1.content);
      print "passed"
    }

@albertnetymk
Copy link
Contributor

OK, clearly now. Thanks.

@EliasC
Copy link
Contributor

EliasC commented Oct 6, 2015

Fixed as of 3619b53.

@EliasC EliasC closed this as completed Oct 6, 2015
@EliasC EliasC removed the bug label Oct 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants