Skip to content

Cannot read property 'validate' of undefined on generics #518

Description

Fixed issue content.

Bit another, real issue. When I trying to use generic class, with generic built-ins, I get error
Cannot read property 'validate' of undefined with generics.

// The entry file of your WebAssembly module.
import "allocator/buddy";

// use v128 for wrapping
class v128_wrap<B> {
  constructor(protected a: v128){ };

  @inline public splat(a: B): v128_wrap<B> { return new v128_wrap<B>(v128.splat<B>(a)); };
  @inline public get(): v128 { return this.a; };
  @inline public extract_lane(a: u8): B { return v128.extract_lane<B>(this.a, a); };
  @inline public set(a: v128): v128_wrap<B> { this.a = a; return this; };

  @inline @operator('+')
  public add(b: v128_wrap<B>): v128_wrap<B> { return new v128_wrap<B>(v128.add<B>(this.get(),b.get())); };
  
  @inline public ptr(): v128_wrap<B> { return this; };
};

//class f32x4_t extends v128_wrap<f32>{};
type f32x4 = v128_wrap<f32>;

let result: f32 = 0.0;
function rise_result(): f32{
  return result;
}

let a = new v128_wrap<f32>(v128.splat<f32>(0.0));
let b = new v128_wrap<f32>(v128.splat<f32>(0.0));
let c = a + b;

//export {rise_result};
C:\Data\Projects\AS-wizard>npm run asbuild

> wizard@1.0.0 asbuild C:\Data\Projects\AS-wizard
> npm run asbuild:untouched && npm run asbuild:optimized


> wizard@1.0.0 asbuild:untouched C:\Data\Projects\AS-wizard
> asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug    --enable mutable-global --enable simd

ERROR: AssertionError: assertion failed
    at t.assert (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:2:132929)
    at t.resolveClass (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:163803)
    at t.resolveClassInclTypeArguments (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:165649)
    at t.compileNewExpression (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:262705)
    at t.compileExpression (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:201903)
    at t.compileExpressionRetainType (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:202693)
    at t.compileGlobal (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:177381)
    at t.compileTopLevelStatement (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:187877)
    at t.compileFile (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:176417)
    at t.compile (C:\Data\Projects\assemblyscript\dist\assemblyscript.js:1:169278)
C:\Data\Projects\assemblyscript\node_modules\binaryen\index.js:7
if(n){p=__dirname+"/";var ea,fa;a.read=function(c,e){var g=q(c);g||(ea||(ea=require("fs")),fa||(fa=require("path")),c=fa.normalize(c),g=ea.readFileSync(c));return e?g:g.toString()};a.readBinary=function(c){c=a.read(c,!0);c.buffer||(c=new Uint8Array(c));assert(c.buffer);return c};1<process.argv.length&&(a.thisProgram=process.argv[1].replace(/\\/g,"/"));a.arguments=process.argv.slice(2);process.on("uncaughtException",function(c){if(!(c instanceof ha))throw c;});process.on("unhandledRejection",u);a.quit=




TypeError: Cannot read property 'validate' of undefined
    at stats.validateTime.measure (C:\Data\Projects\assemblyscript\cli\asc.js:484:19)
    at measure (C:\Data\Projects\assemblyscript\cli\asc.js:804:3)
    at Object.main (C:\Data\Projects\assemblyscript\cli\asc.js:483:27)
    at Object.<anonymous> (C:\Data\Projects\assemblyscript\bin\asc:3:60)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! wizard@1.0.0 asbuild:untouched: `asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug    --enable mutable-global --enable simd`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the wizard@1.0.0 asbuild:untouched script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\helix\AppData\Roaming\npm-cache\_logs\2019-02-27T12_25_31_942Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! wizard@1.0.0 asbuild: `npm run asbuild:untouched && npm run asbuild:optimized`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the wizard@1.0.0 asbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\helix\AppData\Roaming\npm-cache\_logs\2019-02-27T12_25_31_959Z-debug.log

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions