-
-
Notifications
You must be signed in to change notification settings - Fork 688
feat: properly parse and resolve tuples #3018
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8ff13cd
chore: update my email
JairusSW 19cacf9
chore(cli): enable `--enable multi-value` flag
JairusSW 4527d65
feat: wire up support for parsing and resolving tuples
JairusSW c53e659
tests: add tests for tuples
JairusSW 8c480bb
Merge branch 'AssemblyScript:main' into main
JairusSW 6c869a5
tests: organize a bit better and cover more cases
JairusSW b7dfb8f
feat: add support for named tuple types like `[x: f64, y: f64]`
JairusSW 98fe27f
tests: add tests for named tuple types
JairusSW 39eb3f9
chore(cli): keep multi-value feature as unimplemented in the cli since
JairusSW e8563bd
fix: tuples should not be parsed if multi-value is disabled
JairusSW 4b2a399
chore: why did i make it readonly lol
JairusSW 5cc7dce
chore: make sure bootstrapping works
JairusSW 5375b24
chore: revert random formatting changes
JairusSW c8429ce
chore: token check should come before feature
JairusSW 1ca3ad7
chore: update tuple grammer to show named types logically
JairusSW 7c7f000
chore: add options parameter to end of Parser constructor
JairusSW dda5084
chore: add `Readonly<T>` type helper
JairusSW 5874329
tests: add a few tests for empty tuples and more nullable tests
JairusSW e5ab232
chore: revert to options workaround
JairusSW 5ef3d89
Update src/parser.ts
JairusSW d59cbbc
chore: stick with temporary options workaround
JairusSW 301a564
Update src/program.ts
JairusSW a97c523
Update src/parser.ts
JairusSW 9cd4cb2
chore: fix typo and indenting
JairusSW f45638a
tests: test each line/col
JairusSW 729cb2d
fix: `readonly` should be ignored for now
JairusSW 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,9 @@ | ||
| { | ||
| "asc_flags": [ | ||
| "--enable", "multi-value" | ||
| ], | ||
| "stderr": [ | ||
| "TS2456: Type alias 'Loop' circularly references itself.", | ||
| "1 parse error(s)" | ||
| ] | ||
| } |
This file contains hidden or 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 @@ | ||
| type Loop = [Loop, i32]; |
This file contains hidden or 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,9 @@ | ||
| { | ||
| "asc_flags": [ | ||
| "--disable", "multi-value" | ||
| ], | ||
| "stderr": [ | ||
| "TS1110: Type expected.", | ||
| "3 parse error(s)" | ||
| ] | ||
| } |
This file contains hidden or 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,3 @@ | ||
| export function tupleDisabled(x: [left: i32, right: i32]): void {} | ||
| export type tupleTypeDisabled1 = [i32, i32]; | ||
| export type tupleTypeDisabled2 = []; |
This file contains hidden or 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,37 @@ | ||
| { | ||
| "asc_flags": [ | ||
| "--enable", "multi-value" | ||
| ], | ||
| "stderr": [ | ||
| "in tuple-errors.ts(1,13)", | ||
| "in tuple-errors.ts(2,13)", | ||
| "in tuple-errors.ts(3,13)", | ||
| "in tuple-errors.ts(4,13)", | ||
| "in tuple-errors.ts(5,13)", | ||
| "in tuple-errors.ts(6,13)", | ||
| "in tuple-errors.ts(7,13)", | ||
| "in tuple-errors.ts(8,13)", | ||
| "AS100: Not implemented: Tuple types", | ||
| "in tuple-errors.ts(10,45)", | ||
| "in tuple-errors.ts(11,45)", | ||
| "in tuple-errors.ts(12,51)", | ||
| "in tuple-errors.ts(1,39)", | ||
| "in tuple-errors.ts(14,45)", | ||
| "in tuple-errors.ts(15,53)", | ||
| "in tuple-errors.ts(16,45)", | ||
| "in tuple-errors.ts(17,45)", | ||
| "in tuple-errors.ts(19,46)", | ||
| "in tuple-errors.ts(22,46)", | ||
| "in tuple-errors.ts(25,52)", | ||
| "in tuple-errors.ts(31,46)", | ||
| "in tuple-errors.ts(34,54)", | ||
| "in tuple-errors.ts(37,46)", | ||
| "in tuple-errors.ts(40,46)", | ||
| "in tuple-errors.ts(44,15)", | ||
| "in tuple-errors.ts(49,17)", | ||
| "in tuple-errors.ts(53,35)", | ||
| "in tuple-errors.ts(56,35)", | ||
| "in tuple-errors.ts(60,39)", | ||
| "in tuple-errors.ts(63,39)" | ||
| ] | ||
| } |
Oops, something went wrong.
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.
Actually tuple doesn't and is impossible to rely on mutli-value.
In this cases, multiple value cannot handle this case since it treat the whole tuple as a value instead of a heap object.
Uh oh!
There was an error while loading. Please reload this page.
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.
@HerrCai0907, I'll add full support for tuples in the future. Tuples will need to exist in two forms:
multi valuewhen returned from functionstore<[i32, i32]>(),Array<[i32, i32]>), it becomes a heap typeThen, depending on usage, tuples will be lifted and lowered from multi-value to tuple
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.
We’ve been discussing this for a long time, and it’s clear that the only way to ensure that tuples are properly converted to multivalues is to place a
readonlyattribute before them. Otherwise, we’ll have to analyze the control flow for side effects which required custom pass based on binaryen infra.