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

Bug found in PolyList #178

Open
dynastywind opened this issue May 7, 2015 · 8 comments
Open

Bug found in PolyList #178

dynastywind opened this issue May 7, 2015 · 8 comments
Assignees
Labels

Comments

@dynastywind
Copy link

Errors when executing the below codes.

Lyndon-MacBook-Pro:F2JParser Lyndon$ f2j -r bug.sf 
bug using [Naive]
Compiling to Java source code ( ./Bug$.java )
./Bug$.java:287: error: cannot find symbol
    final $PolyList x44 = ($PolyList) x43.temp;
          ^
  symbol:   class $PolyList
  location: class Bug$
./Bug$.java:287: error: cannot find symbol
    final $PolyList x44 = ($PolyList) x43.temp;
                           ^
  symbol:   class $PolyList
  location: class Bug$
2 errors
Error: Could not find or load main class Bug$
rm: cannot remove ‘*.class’: No such file or directory
data PolyList[A] = Nil
            |   Cons A (PolyList[A]);

let rec readPolyList(s: String): PolyList[Char] =
    if s.length() == 0 then (Nil[Char])
    else (Cons[Char] 'a' (readPolyList("")));

readPolyList "a"

Please check.

@xnning
Copy link
Contributor

xnning commented May 7, 2015

Have figured out why.
Be working.

@zhiyuanshi
Copy link
Contributor

@xnning Thanks Ningning! 😺

@xnning
Copy link
Contributor

xnning commented May 12, 2015

@dynastywind Thank you for reporting the bug.
This issue will be delayed until we have a module system.
Currently, please make the final type be a non-datatype.

@zonyitoo
Copy link

I am curious that why my code works? I use this PolyList-like data structure every where ...

Minimal test case

data PList[T] = Nil
              | Cons T (PList[T]);

let singleton[T] (x : T) : PList[T] =
    Cons[T] x (Nil[T]);

singleton[Int] 1

@zonyitoo
Copy link

Temporary work around @dynastywind , just don't make the final type be a non-datatype, like this...

data PList[T] = Nil
              | Cons T (PList[T]);

let singleton[T] (x : T) : PList[T] =
    Cons[T] x (Nil[T]);

let rec showList[T] (show : T -> String) (l : PList[T]) : String =
    case l of
        Nil         -> ""
     |  Cons x xs   -> "\{show x} \{showList[T] show xs}";

showList[Char] (\(x : Char) -> x.toString()) (singleton[Char] 'a’)

@xnning
Copy link
Contributor

xnning commented May 21, 2015

@zonyitoo in latest code, both two should work. Because some predefined files are removed.
But this problem still exists.

@bixuanzju
Copy link
Contributor

@xnning What is the status?

@xnning
Copy link
Contributor

xnning commented Jun 2, 2015

@bixuanzju This issue will be delayed until we have a module system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants