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

Compiling issue: define extractor pattern example from Encore's doc and hit error when compile it #292

Closed
PhucVH888 opened this issue Nov 30, 2015 · 7 comments
Assignees

Comments

@PhucVH888
Copy link
Contributor

When I tried to compile the snippet of code.

#!/usr/bin/env encorec -run

passive class Link {
  assoc : (int, String)
  next  : Link

  def link() : Maybe ((int,String),Link) {
    Just (this.assoc,this.next) }

}

class Main
  def main() : void {
    ()
  }

There is an error message during type checking.

Importing module String from /Users/vo/code/encore/bundles/standard/String.enc
 *** Error during typechecking *** 
"test.enc" (line 7, column 42)
Type 'Maybe ((int, String), Link)' does not match expected type 'Maybe ((int, String), Link)'
In expression: 
  {Just (this.assoc, this.next)}
In method 'link' of type 'Maybe ((int, String), Link)'
In class 'Link'
@EliasC
Copy link
Contributor

EliasC commented Nov 30, 2015

A tip is to try to always reduce the program causing the bug as much as possible. Here is a program with the same error:

passive class Link {
  assoc : (int, int)

  def link() : Maybe (int,int) {
    Just (this.assoc)
  }
}

class Main
  def main() : void {
    ()
  }

This makes it easier to determine what the bug is.

@PhucVH888
Copy link
Contributor Author

yes, I agree with you. Thanks.

@EliasC
Copy link
Contributor

EliasC commented Nov 30, 2015

It seems like the problem is typechecking tuples wrapped in Maybe. Adding a case for tuple types in hasSameKind in src/types/Types.hs should be enough to solve it!

@EliasC
Copy link
Contributor

EliasC commented Nov 30, 2015

I'm too busy to fix it right now, but see if you can get it working by yourself and ask if you get stuck!

@PhucVH888
Copy link
Contributor Author

I have fix it by adding a case areBoth isTupleType || in hasSameKind. It solved the problem.

@EliasC
Copy link
Contributor

EliasC commented Dec 1, 2015

Good! Now it's just a pull request away :)

EliasC added a commit that referenced this issue Dec 14, 2015
Fix #292: adding tuple in `hasSameKind` function in `Type.hs`
@albertnetymk
Copy link
Contributor

Can't reproduce it on development, closing now. Reopen, if not so.

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

5 participants