Discord
Login
Community
DARK THEME

Inner class bug demonstration.

https://microstudio.io/i/Loginus/innerclass/ <<< Comment out the inner class and the code will run.

When I add an internal class to an existing class in the javascript code, all the code written in javascript stops working.

Seems to work with the InnerClass = class { ... syntax.

Also, you're missing a this on the constructor (seems to not work without it):

  createInnerObject() {
    return new this.InnerClass();
  }

The test seems to fail either way, though, but I was able to successfully construct an inner object:

init = function()
  print( "Test run ")

  oc = new OuterClass()
  ic = oc.createInnerObject()
  print(ic)  
end

output:

microScript 2.0 - beta
Test run 
object
  classname = "InnerClass"
  innerField = "inner field"
end

Thanks for the clarification . This code created ChatGPT when I asked it if JavaScript can define a class within a class.

So I was very surprised that the code stopped working after adding the inner class.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community