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

Nested data constructors can lead to dropped functions/variables #203

Open
jazullo opened this issue Mar 24, 2023 · 3 comments
Open

Nested data constructors can lead to dropped functions/variables #203

jazullo opened this issue Mar 24, 2023 · 3 comments

Comments

@jazullo
Copy link
Collaborator

jazullo commented Mar 24, 2023

import Gibbon.Prelude
import Gibbon.Maybe
import Gibbon.PList

print_empty :: () -> PList (Maybe RBT)
print_empty z = 
  let _ = printsym (quote ".") in
  Cons Nothing Nil

x :: PList (Maybe RBT)
x = print_empty ()

Produces error

~/gibbon$ cabal v2-exec gibbon -- --packed --no-gc --to-exe ../llrbt/print_test.hs
gibbon: Function not found: _copy_RBT while checking AppE "_copy_RBT" [] [VarE "x_254"]
at
CallStack (from HasCallStack):
  error, called at src/Gibbon/L1/Typecheck.hs:46:26 in gibbon-0.2-inplace:Gibbon.L1.Typecheck

on master

@jazullo
Copy link
Collaborator Author

jazullo commented Mar 24, 2023

I believe fixing this issue should allow the tree printer in the below code to work. This file currently produces a L2 typechecking variable for a dropped variable, which is both lower down and a different error, but I think they are related?
https://gist.github.com/jazullo/7ac6c4db284b6498b18da3f4957d0c68

@vidsinghal
Copy link
Collaborator

@jazullo this error is there because you haven't included the date type definitions.
Hence the compiler doesn't know what RBT, B, I is.

@vidsinghal
Copy link
Collaborator

import Gibbon.Prelude
import Gibbon.Maybe
import Gibbon.PList

data B = B Bool

data I = I Int

data RBT
  = Empty
  | Node B I RBT RBT

print_empty :: () -> PList (Maybe RBT)
print_empty z = 
  let _ = printsym (quote ".")
      xx :: Maybe RBT 
      xx = Nothing
   in Cons xx (Nil)

x :: PList (Maybe RBT)
x = print_empty ()

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