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

Optional set attributes of a function should be included when binding the set #10632

Closed
yunfachi opened this issue May 1, 2024 · 1 comment
Closed
Labels
breaking Changes we can't make without breaking old expressions, changing hashes, etc feature Feature request or proposal language The Nix expression language; parser, interpreter, primops, evaluation, etc

Comments

@yunfachi
Copy link
Member

yunfachi commented May 1, 2024

Is your feature request related to a problem? Please describe.
When I bind a set with optional attributes, I expect this set to have all required, ignored, specified optional, and unspecified optional attributes, but it only has all required, ignored, and specified optional attributes.

Describe the solution you'd like
When binding a set, unspecified optional attributes should be included.

Describe alternatives you've considered
Creating a new set by inheriting all attributes. For example:
({x, y ? 10}: {inherit x y;}) (x=5;) = { x = 5; y = 10; }

Additional context
In my opinion, they should return the same result, but unspecified attributes are not included

nix-repl> ({x, y ? 10}: {inherit x y;}) {x=5;}
{ x = 5; y = 10; }

nix-repl> ({x, y ? 10} @ args: args) {x=5;} 
{ x = 5; }

Priorities

Add 👍 to issues you find important.

@yunfachi yunfachi added the feature Feature request or proposal label May 1, 2024
@yunfachi yunfachi changed the title Optional set attributes of a function are not binded with the set Optional set attributes of a function should be included when binding the set May 1, 2024
@roberth roberth added language The Nix expression language; parser, interpreter, primops, evaluation, etc breaking Changes we can't make without breaking old expressions, changing hashes, etc labels Jul 5, 2024
@roberth
Copy link
Member

roberth commented Jul 5, 2024

Unfortunately this is not something we can change without causing many expressions to break, which is a no-go for Nix.
Perhaps with a versioned language we could change this, but even then I'd be careful about making the entirety of the language (all versions) more complex.

An alternative that is feasible without versioning the language is to add a new syntax, such as #8636.

I'll add the breaking label so we can find this later, but I'll close it for now because it's not actionable for now.

@roberth roberth closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Changes we can't make without breaking old expressions, changing hashes, etc feature Feature request or proposal language The Nix expression language; parser, interpreter, primops, evaluation, etc
Projects
None yet
Development

No branches or pull requests

2 participants