ruby / TryRuby

This 4th iteration of TryRuby is a website where you can learn the Ruby language.
https://try.ruby-lang.org
MIT License
224 stars 97 forks source link

Using class names suffixed with consecutive numbers triggers type error #137

Closed varungandhi-src closed 1 year ago

varungandhi-src commented 2 years ago
class C1
end

class C2 < C1
end

This gives me an error:

(file): superclass mismatch for class C2 (TypeError)

Renaming the C2 to D fixes the error. I don't know much Ruby, but this seems unexpected... Testing this code locally with 2.7.2 works fine. Is there some internal name modification going on which is creating a class named C2 which is colliding with the hand-written definition?

hsbt commented 2 years ago

@hmdne Can you look this? I think it's issue of Opal.

hmdne commented 1 year ago

The problem is that the Opal runner runs in the browser context, so every constant definition persists. A solution for that could be to run Opal in a web worker.

hmdne commented 1 year ago

I have added an Opal WebWorker runner in #141, but we need to wait for an Opal 1.7.1 release to switch to it.