Skip to content
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

@global causes compile error #2622

Closed
HerrCai0907 opened this issue Jan 19, 2023 · 3 comments · Fixed by #2632
Closed

@global causes compile error #2622

HerrCai0907 opened this issue Jan 19, 2023 · 3 comments · Fixed by #2632
Labels

Comments

@HerrCai0907
Copy link
Member

// index.ts
import {} from "./a"
import {} from "./b"

// a.ts
let a = t;

// b.ts
class T {}
@global export const t = new T();

it causes compile error

ERROR TS2304: Cannot find name 'T'.
   :
 2 │ @global export const t = new T();
   │                              ~
   └─ in assembly/b.ts(2,30)

FAILURE 1 compile error(s)
@HerrCai0907
Copy link
Member Author

I think it is hard to understand why Cannot find name T. Maybe we can give a clearer error message or handle this case in compiler.
@dcodeIO @MaxGraey what is your opinion?

@HerrCai0907
Copy link
Member Author

The working version is

// b.ts
@global class T {}
@global export const t = new T();

@HerrCai0907
Copy link
Member Author

This is a compiler bug, detail see #2624

HerrCai0907 added a commit to HerrCai0907/assemblyscript that referenced this issue Jan 19, 2023
@dcodeIO dcodeIO added the bug label Jan 22, 2023
@dcodeIO dcodeIO mentioned this issue Jan 23, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants