-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
fix: crash on assignment chain #2767
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
(module | ||
(type $i32_i64_=>_none (func (param i32 i64))) | ||
(type $i32_=>_none (func (param i32))) | ||
(type $i32_=>_i64 (func (param i32) (result i64))) | ||
(type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) | ||
(type $none_=>_none (func)) | ||
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) | ||
(global $~lib/memory/__data_end i32 (i32.const 8)) | ||
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 32776)) | ||
(global $~lib/memory/__heap_base i32 (i32.const 32776)) | ||
(memory $0 0) | ||
(table $0 1 1 funcref) | ||
(elem $0 (i32.const 1)) | ||
(export "memory" (memory $0)) | ||
(export "foo" (func $export:assignment-chain/foo)) | ||
(func $assignment-chain/A#set:y (param $this i32) (param $y i64) | ||
local.get $this | ||
local.get $y | ||
i64.store $0 offset=8 | ||
) | ||
(func $assignment-chain/A#get:y (param $this i32) (result i64) | ||
local.get $this | ||
i64.load $0 offset=8 | ||
) | ||
(func $assignment-chain/A#set:x (param $this i32) (param $x i64) | ||
local.get $this | ||
local.get $x | ||
i64.store $0 | ||
) | ||
(func $~stack_check | ||
global.get $~lib/memory/__stack_pointer | ||
global.get $~lib/memory/__data_end | ||
i32.lt_s | ||
if | ||
i32.const 32800 | ||
i32.const 32848 | ||
i32.const 1 | ||
i32.const 1 | ||
call $~lib/builtins/abort | ||
unreachable | ||
end | ||
) | ||
(func $assignment-chain/foo (param $a i32) | ||
(local $1 i32) | ||
(local $2 i32) | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 8 | ||
i32.sub | ||
global.set $~lib/memory/__stack_pointer | ||
call $~stack_check | ||
global.get $~lib/memory/__stack_pointer | ||
i64.const 0 | ||
i64.store $0 | ||
local.get $a | ||
local.set $2 | ||
global.get $~lib/memory/__stack_pointer | ||
local.get $2 | ||
i32.store $0 | ||
local.get $2 | ||
local.get $a | ||
local.tee $1 | ||
local.set $2 | ||
global.get $~lib/memory/__stack_pointer | ||
local.get $2 | ||
i32.store $0 offset=4 | ||
local.get $2 | ||
i64.const 1 | ||
call $assignment-chain/A#set:y | ||
local.get $1 | ||
local.set $2 | ||
global.get $~lib/memory/__stack_pointer | ||
local.get $2 | ||
i32.store $0 offset=4 | ||
local.get $2 | ||
call $assignment-chain/A#get:y | ||
call $assignment-chain/A#set:x | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 8 | ||
i32.add | ||
global.set $~lib/memory/__stack_pointer | ||
) | ||
(func $export:assignment-chain/foo (param $0 i32) | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 4 | ||
i32.sub | ||
global.set $~lib/memory/__stack_pointer | ||
call $~stack_check | ||
global.get $~lib/memory/__stack_pointer | ||
local.get $0 | ||
i32.store $0 | ||
local.get $0 | ||
call $assignment-chain/foo | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 4 | ||
i32.add | ||
global.set $~lib/memory/__stack_pointer | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"asc_flags": [ | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
(module | ||
(type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) | ||
(type $i32_=>_none (func (param i32))) | ||
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) | ||
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 33792)) | ||
(memory $0 0) | ||
(export "memory" (memory $0)) | ||
(export "foo" (func $export:assignment-chain/foo)) | ||
(func $export:assignment-chain/foo (param $0 i32) | ||
(local $1 i32) | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 4 | ||
i32.sub | ||
global.set $~lib/memory/__stack_pointer | ||
block $folding-inner0 | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 1024 | ||
i32.lt_s | ||
br_if $folding-inner0 | ||
global.get $~lib/memory/__stack_pointer | ||
local.tee $1 | ||
local.get $0 | ||
i32.store $0 | ||
local.get $1 | ||
i32.const 8 | ||
i32.sub | ||
global.set $~lib/memory/__stack_pointer | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 1024 | ||
i32.lt_s | ||
br_if $folding-inner0 | ||
global.get $~lib/memory/__stack_pointer | ||
local.tee $1 | ||
i64.const 0 | ||
i64.store $0 | ||
local.get $1 | ||
local.get $0 | ||
i32.store $0 | ||
local.get $1 | ||
local.get $0 | ||
i32.store $0 offset=4 | ||
local.get $0 | ||
i64.const 1 | ||
i64.store $0 offset=8 | ||
local.get $1 | ||
local.get $0 | ||
i32.store $0 offset=4 | ||
local.get $0 | ||
local.get $0 | ||
i64.load $0 offset=8 | ||
i64.store $0 | ||
local.get $1 | ||
i32.const 8 | ||
i32.add | ||
global.set $~lib/memory/__stack_pointer | ||
global.get $~lib/memory/__stack_pointer | ||
i32.const 4 | ||
i32.add | ||
global.set $~lib/memory/__stack_pointer | ||
return | ||
end | ||
i32.const 33824 | ||
i32.const 33872 | ||
i32.const 1 | ||
i32.const 1 | ||
call $~lib/builtins/abort | ||
unreachable | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class A { | ||
x: i64 = 0; | ||
y: i64 = 0; | ||
} | ||
|
||
export function foo(a: A): void { | ||
a.x = a.y = 1; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be calling the getter here? I tried this in the Node.js REPL:
It doesn't seem to call the getter, unless I'm missing something...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do realize you didn't write this, but I wanted to point out what I noticed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use temp variable to store it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,
valueExpr
should be tee'd to a temp local in the setter call, and the getter call should be replaced with a local.get to that local, if I'm correct about not calling that getter.