viebel/klipse

Ruby Parsing Error

soph-g opened this issue · 2 comments

An error is thrown when inputting anything other than an array or hash in the Ruby code snippet tool.

This can be seen in the live demo: https://book.klipse.tech/

Changing the Ruby code example from [1, 2] * 10 to 1 + 1 throws a TypeError, instead of returning 2 as expected.

Tested this behaviour with methods, numbers, strings and symbols - got the same result for all.

I've done some more investigation on this issue and have concluded that the issue was introduced by commit a002aa0, which removed purnam and introduced js-interop. It appears that js-interop can only handle Enumerable objects, as it uses in to find a method before calling it. This throws an error when you try to pass it anything that isn't a Hash or Array.

I can continue to have a look next week, but I don't know why purnam was removed (simplest fix looks like it would be to revert this change). And I'm not 100% sure that I have the whole picture at the moment as I'm new to Clojure.

A tool I maintain is dependent on this package, so any updates on when you might be able to look at resolving this issue would be fantastic.

As a side note, the Ruby test examples don't work, and also are incomplete (only check Hash and Array outputs so don't reveal this error). I would be happy to open a PR to fix this bug and add more examples if that would be useful.

@viebel FYI

fixed by #344