JohnEarnest / ok

An open-source interpreter for the K5 programming language.
MIT License
587 stars 72 forks source link

Weird error message with . (amend) #11

Closed refi64 closed 9 years ago

refi64 commented 9 years ago

Example session:

ryan@DevPC-LX:~/stuff/ok$ nodejs repl.js
oK v0.1

  a:[b:1]
[b:1]
  .[a;`b]
1
  .[a;`b;:;2]        
invalid arguments to [object Object]

I'm pretty sure I'm doing something wrong, but the error here sucks.

Things get even more interesting with normal variables:

ryan@DevPC-LX:~/stuff/ok$ rlwrap nodejs repl.js
oK v0.1

  .[`a;();:;1]
the name 'a' has not been defined.
  a:1
1
  .[`a;();:;1]
Cannot read property 't' of undefined

I'm pretty sure the last one is a bug...

JohnEarnest commented 9 years ago

The first case should be fixed now:

indigo:ok john$ node repl.js 
oK v0.1

  a:[b:1]
[b:1]
  .[a;`b]
1
  .[a;`b;:;2]
[b:2]

As for the second case, it looks like it doesn't function in oK or k5:

john@kbox:~$ rlwrap ./k
2015.04.05 (c) arthur whitney
 .[`a;();:;1]
ERROR: nyi
.[`a;();:;1]
 ^
 a:1
 .[`a;();:;1]
ERROR: nyi
.[`a;();:;1]
 ^

I'll give this some thought.

refi64 commented 9 years ago

@JohnEarnest I'm not complaining about the second case not working; I'm just saying that the error message could be better, e.g. the error should be from oK itself, not JS. :)

Side note: How did you get a copy of K5? The website keeps asking me for a password, and "anonymous" does NOT work.

JohnEarnest commented 9 years ago

Agreed, whenever possible it is desirable to prevent JS errors from "leaking". The issue should be resolved now. As a side note, when encountering errors in the browser-based REPL you can click on error messages to see a JS stack trace which often sheds light on what went wrong.

As for k5, I asked Arthur Whitney nicely and he gave me credentials to download a copy of the interpreter. If you're serious about learning and working with the language I think there's a decent chance he'll let you try it as well. He can be contacted at arthur.whitney@gmail.com.