-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix contract application order in let bindings and annotations (#1544)
* Fix contract application order in let bindings and annotations In a let binding `let foo | A | B = ...` and in an infix contract annotation `foo | A | B` the contracts `A` and `B` were actually being applied in reverse order. That is, first `B`, then `A`. The contract application order for record fields was still correct, however. The root cause was the fact that there were two places with code that merged separate annotations into a single annotation containing multiple contracts. With this change, both spots call into the same code and I've added regression tests to ensure the correct behaviour. * `Annot` -> `Combine` in comments * Add a snapshot test for let-binding contract order
- Loading branch information
Showing
7 changed files
with
136 additions
and
102 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# capture = 'stdout' | ||
# command = ['pprint-ast'] | ||
let foo : String | String | std.string.NonEmpty = "some very long string to blow past the 80 character line length limit" in foo |
11 changes: 11 additions & 0 deletions
11
cli/tests/snapshot/snapshots/snapshot__pprint-ast_stdout_let_annotations.ncl.snap
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,11 @@ | ||
--- | ||
source: cli/tests/snapshot/main.rs | ||
expression: out | ||
--- | ||
let foo | ||
: String | ||
| String | ||
| std.string.NonEmpty | ||
= "some very long string to blow past the 80 character line length limit" | ||
in | ||
foo |
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
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
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,15 @@ | ||
# test.type = 'pass' | ||
let { check, Assert, .. } = import "../lib/assert.ncl" in | ||
let ConstantTrue = fun _label value => std.seq value true in | ||
[ | ||
let foo | ConstantTrue | Bool = "not a bool" in | ||
foo, | ||
|
||
{ | ||
foo | ||
| ConstantTrue | ||
| Bool | ||
= "still not a bool" | ||
}.foo | ||
] | ||
|> check |