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

stack overflow in the code generator #12

Open
ks32849 opened this issue Jul 16, 2012 · 1 comment
Open

stack overflow in the code generator #12

ks32849 opened this issue Jul 16, 2012 · 1 comment

Comments

@ks32849
Copy link

ks32849 commented Jul 16, 2012

filter(criteria, ls) =>
*, [] : []
*, [x:xs] | criteria.@call(x) : [x] + filter(criteria,xs)
| else : filter(criteria, xs)

main ->
print(filter(divBy2, [1..20]))
where
divBy2: @(n) -> {(n % 2) == 0}

This causes an infinite loop and eventually a stack overflow in the code generator:
Exception in thread "main" java.lang.StackOverflowError
at java.util.regex.Pattern.append(Unknown Source)
at java.util.regex.Pattern.atom(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceFirst(Unknown Source)
at loop.AsmCodeEmitter.normalizeMethodName(AsmCodeEmitter.java:720)
at loop.AsmCodeEmitter.access$500(AsmCodeEmitter.java:68)
at loop.AsmCodeEmitter$18.emitCode(AsmCodeEmitter.java:971)
at loop.AsmCodeEmitter.emit(AsmCodeEmitter.java:235)
at loop.AsmCodeEmitter$6.emitCode(AsmCodeEmitter.java:649)
at loop.AsmCodeEmitter.emit(AsmCodeEmitter.java:235)
at loop.AsmCodeEmitter$18.emitCode(AsmCodeEmitter.java:1001)
at loop.AsmCodeEmitter.emit(AsmCodeEmitter.java:235)
at loop.AsmCodeEmitter$6.emitCode(AsmCodeEmitter.java:649)
etc.

Where as:

main ->
print(filter( @(n) -> {(n % 2) == 0} , [1..20]))
works great. So does:

main ->
print(filter(divBy2, [1..20]))
where
divBy2(n) ->
(n % 2) == 0

@dhanji
Copy link
Owner

dhanji commented Jul 31, 2012

Looking at this, sorry about the delay.

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

2 participants