-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Respect variable type ascription when initializer has type Never #6911
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 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0a2dc2f
Add test
jjcnn 1c0e2bd
Fix test case
jjcnn f74ca11
Attempted solution + debugs
jjcnn 554c20c
Code cleanup
jjcnn f9ca5eb
Merge branch 'master' into jjcnn/unify_never
jjcnn 016a942
Tab issues
jjcnn 40b5cdf
Merge branch 'jjcnn/unify_never' of github.com:FuelLabs/sway into jjc…
jjcnn 72cde35
Whitespace
jjcnn 5c02191
clippy, fmt
jjcnn 6746694
Merge branch 'master' into jjcnn/unify_never
JoshuaBatty a38a15d
Merge branch 'master' into jjcnn/unify_never
IGI-111 eadf708
Untabify
jjcnn e44b0bb
Merge branch 'jjcnn/unify_never' of github.com:FuelLabs/sway into jjc…
jjcnn 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ fn diverge_in_match_condition() -> u64 { | |
return 5; | ||
true | ||
} { | ||
_ => 42, | ||
} | ||
} | ||
|
||
|
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/should_pass/language/unify_never/Forc.lock
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,13 @@ | ||
[[package]] | ||
name = "core" | ||
source = "path+from-root-DFCFC85C94C0C9BD" | ||
|
||
[[package]] | ||
name = "std" | ||
source = "path+from-root-DFCFC85C94C0C9BD" | ||
dependencies = ["core"] | ||
|
||
[[package]] | ||
name = "unify_never" | ||
source = "member" | ||
dependencies = ["std"] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/unify_never/Forc.toml
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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
license = "Apache-2.0" | ||
name = "unify_never" | ||
entry = "main.sw" | ||
|
||
[dependencies] | ||
std = { path = "../../../../reduced_std_libs/sway-lib-std-assert" } |
19 changes: 19 additions & 0 deletions
19
test/src/e2e_vm_tests/test_programs/should_pass/language/unify_never/src/main.sw
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,19 @@ | ||
script; | ||
|
||
// Test of unification of the Never type | ||
|
||
fn test_1(){ | ||
let mut v1: u32 = 1; | ||
v1 = return; | ||
} | ||
|
||
fn test_2(){ | ||
let mut v2: u32 = return; | ||
v2 = 1; | ||
} | ||
|
||
|
||
fn main() { | ||
test_1(); | ||
test_2(); | ||
} |
2 changes: 2 additions & 0 deletions
2
test/src/e2e_vm_tests/test_programs/should_pass/language/unify_never/test.toml
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,2 @@ | ||
category = "compile" | ||
expected_warnings = 1 |
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.
Uh oh!
There was an error while loading. Please reload this page.