mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-22 11:11:43 +00:00
Cleanup; Fix an issue with 'let' declarations reusing a local
This commit is contained in:
@ -1,9 +1,13 @@
|
||||
(module
|
||||
(type $iv (func (param i32)))
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(func $scoped/fn (; 0 ;) (type $iv) (param $0 i32)
|
||||
(nop)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(loop $continue|0
|
||||
(if
|
||||
@ -42,5 +46,8 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(call $scoped/fn
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -12,3 +12,15 @@ for (let aGlobal /* that shadows */: i32 = 0; aGlobal < 1; ++aGlobal)
|
||||
let /* still not */ aConstant: f32 = 10;
|
||||
}
|
||||
}
|
||||
|
||||
// regression test: reused local should be updated with new requested type
|
||||
function fn(c: i32): void {
|
||||
{
|
||||
let a: bool = 0;
|
||||
}
|
||||
{
|
||||
let b: i32;
|
||||
b = c; // should not issue a conversion warning mentioning 'bool'
|
||||
}
|
||||
}
|
||||
fn(42);
|
||||
|
@ -1,4 +1,5 @@
|
||||
(module
|
||||
(type $iv (func (param i32)))
|
||||
(type $v (func))
|
||||
(global $scoped/aGlobal (mut i32) (i32.const 1))
|
||||
(global $scoped/aConstant i32 (i32.const 3))
|
||||
@ -7,7 +8,28 @@
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(func $scoped/fn (; 0 ;) (type $iv) (param $0 i32)
|
||||
(local $1 i32)
|
||||
;;@ scoped.ts:18:2
|
||||
(block
|
||||
;;@ scoped.ts:19:4
|
||||
(set_local $1
|
||||
;;@ scoped.ts:19:18
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
;;@ scoped.ts:21:2
|
||||
(block
|
||||
;;@ scoped.ts:22:4
|
||||
(nop)
|
||||
;;@ scoped.ts:23:4
|
||||
(set_local $1
|
||||
;;@ scoped.ts:23:8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i64)
|
||||
@ -92,5 +114,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ scoped.ts:26:0
|
||||
(call $scoped/fn
|
||||
;;@ scoped.ts:26:3
|
||||
(i32.const 42)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user