#2770 JS: Type methods (undefined)

SlimerDude Wed 4 Sep

Methods on a Fantom JS Type don't seem to exist!?

@Js class TestStuff : Test {
    Void testCtor() {
        TestStuff#.methods
    }
}

Heralds:

> fan compilerJs::NodeRunner -test acme::TestStuff

C:\Apps\nodejs-9.4.0\node.exe

-- Run: acme::TestStuff.testCtor...
TypeError: Cannot read property 'size' of undefined (Unknown:Unknown)

Failed:
  acme::TestStuff.testCtor

Is this right?

andy Thu 5 Sep

Not seeing that issue in browsers -- so might be an issue with how we're bootstrapping the nodejs vm -- not sure. Any more details?

SlimerDude Thu 5 Sep

Well, I can do this:

@Js class TestStuff : Test {
    Void testCtor() {
        echo("Hello!")
        try TestStuff#.methods
        catch (Err err) err.trace
    }
}

which gives:

>fan compilerJs::NodeRunner -test acme -keep
C:\Apps\nodejs-10.16.3\node.exe

-- Run: acme::TestStuff.testCtor...
Hello!
sys::Err: Cannot read property 'size' of undefined
TypeError: Cannot read property 'size' of undefined
    at fan.sys.Type.doReflect (    at fan.sys.Type.doReflect (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6468:31)
    at fan.sys.Type.reflect (    at fan.sys.Type.reflect (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6460:6)
    at fan.sys.Type.$mergeType (    at fan.sys.Type.$mergeType (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6491:36)
    at fan.sys.Type.doReflect (    at fan.sys.Type.doReflect (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6469:6)
    at fan.sys.Type.reflect (    at fan.sys.Type.reflect (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6460:6)
    at fan.sys.Type.$mergeType (    at fan.sys.Type.$mergeType (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6491:36)
    at fan.sys.Type.doReflect (    at fan.sys.Type.doReflect (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6469:6)
    at fan.sys.Type.reflect (    at fan.sys.Type.reflect (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6460:6)
    at fan.sys.Type.methods (    at fan.sys.Type.methods (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\sys.js:6317:59)
    at fan.acme.TestStuff.testCtor (    at fan.acme.TestStuff.testCtor (C:\Apps\fantom-1.0.73\temp\nodeRunner\node_modules\acme.js:24:30)

   Pass: acme::TestStuff.testCtor [0]

And the acme.js file looks like:

(function () {
var root=this;
var fan=root.fan;
if (!fan && (typeof require !== 'undefined')) fan = require('sys.js');

if (typeof exports !== 'undefined') {
  fan.acme = exports;
} else {
  fan.acme = root.fan.acme = {};
}

...
...

fan.acme.TestStuff.prototype.testCtor = function()
{
  fan.sys.ObjUtil.echo("Hello!");
  try
  {
    fan.acme.TestStuff.$type.methods();
  }
  ...
  ...

Does that help?

andy Thu 5 Sep

Ticket promoted to #2770 and assigned to andy

Yeah that helps -- will take a look

Login or Signup to reply.