Repository navigation
fix: review findings that don't involve Any, and simplifications 🧹 #345
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
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
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
7 changes: 7 additions & 0 deletions
7
...rograms/005_functions/105_a_nested_function_takes_a_literal_call_from_one_further_out.ndc
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,7 @@ | ||
| // The nearest scope with a function that takes a call is the call's, so a | ||
| // later call with another type can't hand an earlier one to an outer `d`. | ||
| // expect-output: inner inner | ||
| fn d(x: Int) => "outer"; | ||
| fn run() { fn d(x) => "inner"; d(1) } | ||
| fn run2() { fn d(x) => "inner"; let r = d(1); d(2.5); r } | ||
| print(run(), run2()); |
9 changes: 9 additions & 0 deletions
9
...ms/005_functions/106_a_nested_function_waits_for_other_arguments_before_taking_a_call.ndc
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 @@ | ||
| // A call whose other arguments aren't known yet waits for them before the | ||
| // nearest scope takes it: `y` may make the outer `d` the one that fits. | ||
| // expect-output: outer | ||
| fn d(x: Int, y: String) => "outer"; | ||
| fn run(y) { | ||
| fn d(x, y: Int) => "inner"; | ||
| d(1, y) | ||
| } | ||
| print(run("s")); |
6 changes: 3 additions & 3 deletions
6
tests/functional/programs/008_iterators/007_range_bound_types.ndc
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // Every non-Int bound used to claim the integer was too large. Only an | ||
| // integer that genuinely does not fit is a size problem. | ||
| // expect-error: range bounds must be Int, got Number | ||
| // Every non-Int bound used to claim the integer was too large. A range | ||
| // counts in Ints, so a Number bound is reported before the program runs. | ||
| // expect-error: mismatched types: found Number but expected Int | ||
| for i in 0n..3n { print(i); } |
10 changes: 10 additions & 0 deletions
10
tests/functional/programs/008_iterators/008_a_range_bound_is_an_int.ndc
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,10 @@ | ||
| // A range counts in Ints, so a literal used as its bound is an Int, and a | ||
| // list mixing it with a Float holds `Any`s. | ||
| // expect-output: 3 [0.5,3] | ||
| let n = 3; | ||
| let xs = [0.5, n]; | ||
| let total = 0; | ||
| for i in 0..n { | ||
| total += i; | ||
| } | ||
| print(total, xs); |
7 changes: 7 additions & 0 deletions
7
tests/functional/programs/009_slicing/013_a_list_slice_takes_any_sequence.ndc
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,7 @@ | ||
| // A list slice can be assigned any sequence of its element type. | ||
| // expect-output: [1,5,6] [8,9,3] | ||
| let xs = [1, 2, 3]; | ||
| xs[1..3] = 5..7; | ||
| let ys = [1, 2, 3]; | ||
| ys[0..2] = (8, 9); | ||
| print(xs, ys); |
Oops, something went wrong.
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.
When another argument is an unresolved nonliteral type variable,
takes_any_literaldoes not establish that this overload will still accept the call once that argument is known. For example,fn d(x: Int, y: String) => "outer"; fn run(y) { fn d(x, y: Int) => "inner"; d(1, y) } print(run("s"));now commits to the innerdwhile analysingrun, forcingytoIntand rejecting the String call. Previously, both scopes remained viable until the call supplied String, allowing the outer overload to be selected. Keep this call undecided unless the nonliteral arguments also cannot change which scope accepts it.Useful? React with 👍 / 👎.