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

Endless loop/memory allocation when using type aliases #2

Closed
talios opened this issue Oct 5, 2013 · 8 comments
Closed

Endless loop/memory allocation when using type aliases #2

talios opened this issue Oct 5, 2013 · 8 comments
Assignees

Comments

@talios
Copy link

talios commented Oct 5, 2013

Whilst working on some code samples for a presentation, I found the following code will cause the FregeREPL to dive into an endless loop when trying to call show cust.

type Currency = String
data Customer = Customer { name :: String, currency :: Currency }
derive Show Customer
cust = Customer "Mark" "NZD"

show cust

A sampling of a thread dump is at https://gist.github.com/talios/ec13155910ab52a54ce2 .

@Ingo60
Copy link
Member

Ingo60 commented Oct 5, 2013

The function deepdep that occurs often in the stack trace is local to Utilities.tsort (topological sort).
This function is used frequently on classes, type aliases and top level functions to detect mutual recursivity, which is forbidden for superclass relationships and type aliases, e.g. you can't have:

type A = B
type B = A

Since the error seems to manifest itself when there are type declarations, I guess it is called in the "check type aliases" pass (TAlias.pass).
The same code does work in the compiler, so it would be useful to somehow see what the REPL is doing there.
I hope @mmhelloworld can help us here.

@ghost ghost assigned mmhelloworld Oct 5, 2013
@mmhelloworld
Copy link
Member

The problem is that the REPL will call show to print the result if the expression is not of type String. The code that returns the type in this case returns the type alias (Currency) which is in fact String but REPL couldn't unify that so it keeps on calling show and ends up in a loop.

I am working on it. The REPL changes for the latest Frege are also done so I will upload a new jar along with this fix in few hours.

@Ingo60
Copy link
Member

Ingo60 commented Oct 5, 2013

The type unaliasing takes only place if you use "nicer", maybe you can use "nice" only and check if it is StringJ Char

@mmhelloworld
Copy link
Member

Thanks Ingo. I tried that but It still returns the type alias name.

@mmhelloworld
Copy link
Member

My mistake! I explicitly called unAlias. It works now after removing unAlias.

@mmhelloworld
Copy link
Member

This issue is fixed and the fix is available in the latest REPL for Frege 3.21.232-g7b05453. The REPL is available in the releases page here.

@talios
Copy link
Author

talios commented Oct 6, 2013

You rock ;-)

On 6/10/2013, at 7:44 PM, Marimuthu Madasamy [email protected] wrote:

This issue is fixed and the fix is available in the latest REPL for Frege 3.21.232-g7b05453. The REPL is available in the releases page here.


Reply to this email directly or view it on GitHub.

@mmhelloworld
Copy link
Member

Thanks! :)

This issue was closed.
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