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

Error Illegal forward or cyclic type inference causes java.lang.StackOverflowError #3347

Open
simonvonhackewitz opened this issue Jul 9, 2024 · 0 comments
Assignees
Labels
bug Something isn't working front end related to the front end until .fum file is created: call and type resolution, type checking, etc.

Comments

@simonvonhackewitz
Copy link
Contributor

simonvonhackewitz commented Jul 9, 2024

This is the faulty code

out :=
  for res := [], res ++ new_res
      i := 0, i+1
  while i<10
  do
    new_res := [i]

say out

And the error is

/home/simon/playground/java_exception_test.fz:2:7: error 1: Illegal forward or cyclic type inference
  for res := [], res ++ new_res
------^^^
The definition of a field using ':=', or of a feature or function
using '=>' must not create cyclic type dependencies.
Referenced feature: 'res' at /home/simon/playground/java_exception_test.fz:2:7:
  for res := [], res ++ new_res
------^^^


error 2: java.lang.StackOverflowError
        at dev.flang.ast.Assign.<init>(Assign.java:117)
        at dev.flang.ast.Feature$9.<init>(Feature.java:2047)
        at dev.flang.ast.Feature.resolveTypes(Feature.java:2046)
        at dev.flang.ast.Feature$ResolveTypes.action(Feature.java:1379)
        at dev.flang.ast.Feature.visit(Feature.java:2013)
        at dev.flang.ast.Impl.inferredType(Impl.java:616)
        at dev.flang.ast.Feature.resultTypeIfPresent(Feature.java:2349)
        at dev.flang.ast.AbstractAssign.resultTypeKnown(AbstractAssign.java:245)
        ...
@fridis fridis self-assigned this Jul 9, 2024
@fridis fridis added bug Something isn't working front end related to the front end until .fum file is created: call and type resolution, type checking, etc. labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working front end related to the front end until .fum file is created: call and type resolution, type checking, etc.
Projects
None yet
Development

No branches or pull requests

2 participants