-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unsound record contract deduplication (#2042)
* Fix contract equality unsound on records Contract equality code used to flat out ignore all of the metadata of a fields, including contract annotations, which is obviously entirely wrong. This means that `{foo | String}` and `{foo | Number}` was deemed equal and deduplicated as the same contract. This commit fixes the issue by comparing the metadata as well. Contract labels are a subtle matter, and they are the only part that is ignored by the contract equality code. * Add comparison of label's type_environment for safety * Update core/src/typecheck/eq.rs Co-authored-by: jneem <[email protected]> * Add integration test for contract dedup unsoundness --------- Co-authored-by: jneem <[email protected]>
- Loading branch information
Showing
2 changed files
with
100 additions
and
2 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
49 changes: 49 additions & 0 deletions
49
core/tests/integration/inputs/contracts/unsound_dedup_record_contract.ncl
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,49 @@ | ||
# test.type = 'error' | ||
# eval = 'full' | ||
# | ||
# [test.metadata] | ||
# error = 'EvalError::BlameError' | ||
|
||
# Regression test for https://github.com/tweag/nickel/issues/1700 | ||
let outer = { | ||
spec | ||
| { | ||
hostAliases | Number, | ||
containers | Number, | ||
}, | ||
} | ||
in | ||
|
||
let inner = { | ||
spec | ||
| { | ||
hostAliases, | ||
containers | ||
| Array { | ||
.. | ||
}, | ||
}, | ||
} | ||
in | ||
|
||
std.deep_seq | ||
( | ||
{ | ||
spec = { | ||
hostAliases = "this should fail", | ||
containers = [ | ||
{ | ||
name = "test", | ||
image = "nginx", | ||
ports = [ | ||
{ | ||
containerPort = 80, | ||
name = "http" | ||
} | ||
], | ||
} | ||
] | ||
} | ||
} | inner | outer | ||
) | ||
true |