-
Notifications
You must be signed in to change notification settings - Fork 3k
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
erl_lint: Warn on updating map/record literals #8069
erl_lint: Warn on updating map/record literals #8069
Conversation
CT Test Results 2 files 93 suites 35m 18s ⏱️ Results for commit 239f7c1. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
This is definitely a very welcome change. How does this interact with macros? Some code I've seen is shaped like: -define(FOO_DEFAULT, #foo{...}).
?FOO_DEFAULT#foo{custom = value} I'm not sure this should be a concern, but just something to consider. |
|
As a reference, this can be bypassed in macros by wrapping the literal map that's meant to be updated immediately in a -define(range_anno(Tok1, Tok2), begin #{
location => map_get(location, ?anno(Tok1)),
end_location => map_get(end_location, ?anno(Tok2))
} end). And then We hit this in erlfmt - WhatsApp/erlfmt#354 |
Silence "expression updates a literal" compiler lint recently introduced in erlang/otp#8069.
Silence "expression updates a literal" compiler lint recently introduced in erlang/otp#8069.
This PR adds a warning whenever a literal map or record is updated, catching errors like missing commas in lists of records:
https://erlangforums.com/t/maybe-a-bug-compiling-a-list-of-records-without-comma-between-them/3239