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

Let expressions are not recursive #223

Open
jazullo opened this issue Aug 16, 2023 · 1 comment
Open

Let expressions are not recursive #223

jazullo opened this issue Aug 16, 2023 · 1 comment

Comments

@jazullo
Copy link
Collaborator

jazullo commented Aug 16, 2023

Take the following simple example.

fac :: Int -> Int
fac x = 
  let
    go n = if n > 0 then n * go (n-1) else 1
  in
    go x

This compiles under GHC, but Gibbon yields the following error:

gibbon: L0.Typecheck:
    Unknown function: go in Var "fac"
CallStack (from HasCallStack):
  error, called at src/Gibbon/L0/Typecheck.hs:83:18 in gibbon-0.2-inplace:Gibbon.L0.Typecheck

Evidently let expressions are not typechecked with a recursive context, giving us an unbound identifier go. Supporting the singly recursive case is probably not too troublesome since a recursive context can be made with laziness, a mutually recursive case would probably be too difficult since our let expressions are separated out into single assignments at the AST level.

@rrnewton
Copy link
Member

We discussed on the call a strategy to:

  • add LetRec to L0 only
  • desugar on the way to L1

More details could be fleshed out here.

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