Skip to content
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

Contract attached to record key not getting evaluated #1774

Closed
suimong opened this issue Jan 24, 2024 · 1 comment · Fixed by #1778
Closed

Contract attached to record key not getting evaluated #1774

suimong opened this issue Jan 24, 2024 · 1 comment · Fixed by #1778
Assignees
Labels
area: contracts P0 blocker: fix immediately! type: bug

Comments

@suimong
Copy link
Contributor

suimong commented Jan 24, 2024

Describe the bug
I'm seeing a weird behavior with v1.4.0 (not sure about how far back it goes though), that contracts attaching to a key is not evaluated, only contracts that attach after the value gets evaluated.

To Reproduce
Using the sample code from the documentation:

# sample.ncl

{
    OptLevel = std.contract.from_predicate (fun value =>
      std.array.elem value ["O0", "O1", "O2", "O3"])
    ,
    level = 4
    ,
    opt_level | OptLevel = "A" ++ std.string.from_number level,
    opt_level2 = ("A" ++ std.string.from_number level) | OptLevel,
}
nickel eval sample.ncl --field=opt_level   # evaluates to "A4", which is wrong
nickel eval sample.ncl --field=opt_level2  # contract broken by a value, which is expected

Environment

  • OS name + version: NixOS 23.11
  • Version of the code: nickel 1.4.0 (rev 1fa5a79)

Additional context
Add any other context about the problem here.

@yannham yannham added P0 blocker: fix immediately! type: bug area: contracts labels Jan 24, 2024
@yannham yannham self-assigned this Jan 24, 2024
@yannham
Copy link
Member

yannham commented Jan 24, 2024

This isn't good 🙃

After a bit more experimentation, it seems only the --field argument is concerned (it was introduced in 1.3, IIRC). A fix is on the way, and this might mandate a 1.4.1 release - silently ignoring contracts is bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: contracts P0 blocker: fix immediately! type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants