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 const optimization #13

Closed
blooddy opened this issue Jan 14, 2018 · 7 comments
Closed

global const optimization #13

blooddy opened this issue Jan 14, 2018 · 7 comments

Comments

@blooddy
Copy link

blooddy commented Jan 14, 2018

const A:i32 = 1;
const B:i32 = A + 1;

export function test():i32 {
    return B;
}

output

// module.ts(2,15): warning TS/AS121: Compiling global with unsupported constant initializer expression as mutable.

(module
 (type $i (func (result i32)))
 (type $v (func))
 (global $B (mut i32) (i32.const 0))
 (memory $0 1)
 (export "test" (func $test))
 (export "memory" (memory $0))
 (start $.start)
 (func $test (; 0 ;) (type $i) (result i32)
  (get_global $B)
 )
 (func $.start (; 1 ;) (type $v)
  (set_global $B
   (i32.const 2)
  )
 )
)
@dcodeIO
Copy link
Member

dcodeIO commented Jan 14, 2018

This seems like a bug and should actually be supported.

@dcodeIO dcodeIO added the bug label Jan 14, 2018
@dcodeIO
Copy link
Member

dcodeIO commented Jan 14, 2018

Wait, are you using the prototype from npm? In master it should be start instead of .start. So this might not be a bug but due to the prototype not supporting it.

@dcodeIO dcodeIO removed the bug label Jan 14, 2018
@blooddy
Copy link
Author

blooddy commented Jan 14, 2018

im using web http://assemblyscript.org/try/

@dcodeIO
Copy link
Member

dcodeIO commented Jan 14, 2018

I see, that's still the prototype as well.

@blooddy
Copy link
Author

blooddy commented Jan 14, 2018

Are you going to update the web version?

@dcodeIO
Copy link
Member

dcodeIO commented Jan 14, 2018

Sure, going to do that eventually. Ideally once arrays and strings are implemented.

@dcodeIO
Copy link
Member

dcodeIO commented Feb 17, 2018

AssemblyScript is now available as a template in WebAssembly Studio. Basically a better playground :)

@dcodeIO dcodeIO closed this as completed Feb 17, 2018
willemneal pushed a commit to willemneal/assemblyscript that referenced this issue May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants