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

Add convert_let_attrset assist #64

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MoritzBoehme
Copy link
Contributor

@MoritzBoehme MoritzBoehme commented Mar 4, 2023

I'm not very happy with how the choice between body and bindings works.
If anyone is reading this and has some spare time, feel free to suggest better ways to do this.

@MoritzBoehme MoritzBoehme changed the title Add replace_let_attrset assist Add convert_let_attrset assist Mar 4, 2023
@oxalica
Copy link
Owner

oxalica commented Mar 4, 2023

Is this really useful? I have not seen any let {} in wild besides accidental usages like typos. So only a warning is enough to me.

Also note that let { ... } desugars to rec { ... }.body, all fields including body can mutual reference, and body is accessed at eval-time. Your conversion doesn't preserve semantics in all cases.

let { a = [ body ]; body = [ a ]; } # Valid and evaluates to an infinite list.
let a = [ body ]; in [ a ] # Syntactically invalid. (Parse failed for Nix)
let a = [ body ]; body = [ a ]; in body # Valid. Same result.
let { } # Syntactically valid but error when evaluated.
let in body # Syntactically invalid. (Parse failed for Nix)

@MoritzBoehme
Copy link
Contributor Author

Is this really useful?

Probably not. I had to look up how the old let worked and only found 2 examples in total.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants