Skip to content

Fix calling required extractors through traits#304

Merged
supercooldave merged 1 commit into
parapluu:developmentfrom
EliasC:fix/match-trait-extractor
Dec 18, 2015
Merged

Fix calling required extractors through traits#304
supercooldave merged 1 commit into
parapluu:developmentfrom
EliasC:fix/match-trait-extractor

Conversation

@EliasC

@EliasC EliasC commented Dec 17, 2015

Copy link
Copy Markdown
Contributor

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