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

Fix calling required extractors through traits #304

Merged
merged 1 commit into from
Dec 18, 2015
Merged

Fix calling required extractors through traits #304

merged 1 commit into from
Dec 18, 2015

Conversation

EliasC
Copy link
Contributor

@EliasC EliasC commented Dec 17, 2015

The following program generated faulty C-code:

trait Result<b> {
  require Success() : Maybe b
}
passive class Success<b> : Result<b> {
  data : b
  def init(data : b) : void {
    this.data = data
  }
  def Success() : Maybe b {
    Just this.data
  }
}
class Main {
  foo : Result<int>
  def main() : void {
    this.foo = new Success<int>(5);
    match this.foo with
      Success(x) => print("It's a success! The resulting value is {}\n", x)
  }
}

The problem was that the extractor code was assuming that the extractor
was a method defined in a class, so it would not work for trait types.

The following program generated faulty C-code:

```
trait Result<b> {
  require Success() : Maybe b
}
passive class Success<b> : Result<b> {
  data : b
  def init(data : b) : void {
    this.data = data
  }
  def Success() : Maybe b {
    Just this.data
  }
}
class Main {
  foo : Result<int>
  def main() : void {
    this.foo = new Success<int>(5);
    match this.foo with
      Success(x) => print("It's a success! The resulting value is {}\n", x)
  }
}
```

The problem was that the extractor code was assuming that the extractor
was a method defined in a class, so it would not work for trait types.
@supercooldave supercooldave merged commit 9ecf898 into parapluu:development Dec 18, 2015
@supercooldave supercooldave deleted the fix/match-trait-extractor branch December 18, 2015 11:53
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

Successfully merging this pull request may close these issues.

2 participants