You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inspired by this discussion question: #1458. We should have error messages point at a particular field definition in a record, when that makes sense. For example, the code
let Contract = { foo, bar } in
{
foo = 5,
bar = 6,
baz = 2,
} | Contract
produces an error message that starts with
error: contract broken by a value: extra field `baz`
┌─ fruits.ncl:2:1
│
2 │ ╭ {
3 │ │ foo = 5,
4 │ │ bar = 6,
5 │ │ baz = 2,
6 │ │ }
│ ╰─^ applied to this expression
7 │ | Contract
│ -------- expected type
Note that the term being blamed is the entire definition of the record while, arguably, the problem is with the definition of baz. Especially for very large records this could make the difference between an easily localized problem and a frustrating debug session. Just imagine a record like the top-level of nixpkgs.
We should also find some way to make this feature available to user writter contracts. There should be some function on blame labels that could be used to point it at a specific record field name, not just at a field value as could be achieved with std.contract.apply.
The text was updated successfully, but these errors were encountered:
Inspired by this discussion question: #1458. We should have error messages point at a particular field definition in a record, when that makes sense. For example, the code
produces an error message that starts with
Note that the term being blamed is the entire definition of the record while, arguably, the problem is with the definition of
baz
. Especially for very large records this could make the difference between an easily localized problem and a frustrating debug session. Just imagine a record like the top-level of nixpkgs.We should also find some way to make this feature available to user writter contracts. There should be some function on blame labels that could be used to point it at a specific record field name, not just at a field value as could be achieved with
std.contract.apply
.The text was updated successfully, but these errors were encountered: