Skip to content

ERROR TS2391: Function implementation is missing or not immediately following the declaration. #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LiaoPeng opened this issue Jul 5, 2018 · 4 comments
Labels

Comments

@LiaoPeng
Copy link
Contributor

LiaoPeng commented Jul 5, 2018

The code:

import "allocator/arena";

interface Car{
	getBrand():string;
}

export class Audi implements Car{
	getBrand():string{
		return "audi";
	}
}
let audi = new Audi();

When I compile using asc, it throw exception:

ERROR TS2391: Function implementation is missing or not immediately following the declaration.

 	getBrand():string;
             ~~~~~~
 in test_impl.ts(5,12)

ERROR: Parse error
    at Object.main (/Users/Peng/GitHub/assemblyscript/cli/asc.js:377:23)
    at Object.<anonymous> (/Users/Peng/GitHub/assemblyscript/bin/asc:3:60)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
    at startup (internal/bootstrap/node.js:228:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:575:3)

If I change the getBrand():string; to getBrand():string{};, it compiles fine.
It looks FunctionPrototype not finished.

/** A yet unresolved function prototype. */
export class FunctionPrototype extends Element {

I want to contribute some code, what shall I do?

@dcodeIO
Copy link
Member

dcodeIO commented Jul 5, 2018

Interfaces are not yet supported and apparently don't initialize properly.

@LiaoPeng
Copy link
Contributor Author

LiaoPeng commented Jul 5, 2018

@dcodeIO Thanks for your replay.Are the interfaces supported on the way?

@dcodeIO
Copy link
Member

dcodeIO commented Jul 9, 2018

There are no plans to support interfaces just now because implementing these properly requires support for virtual methods (virtual lookup tables etc. etc.), and the plan currently is to wait for the GC spec to land instead of rolling our own, possibly large, runtime. GC is tracked here: #89

@dcodeIO
Copy link
Member

dcodeIO commented Oct 20, 2019

From a quick test it seems that the specific error has been fixed meanwhile, resulting in a "Not implemented" warning on "implements Car". Still not working, ofc, but the warning is intended and not a bug anymore. Hence closing, but feel free to reopen if there's still something exploding :)

@dcodeIO dcodeIO closed this as completed Oct 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants