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

struct update deprecated sytnax #4586

Merged
merged 3 commits into from
Mar 11, 2025
Merged

Conversation

IvanIvanoff
Copy link
Member

@IvanIvanoff IvanIvanoff commented Mar 10, 2025

Changes

  • Stop using %StructModule{struct | ...} update syntax
  • Find and remove some more %StructModule{struct | ...} update syntax occurrences
    • Use regex %(\w+)\{[\r\n\s]*(?<struct>\w+)[\r\n\s]* \| and replace with %{$2 |
  • Add pattern matching in function header

Relevant Elixir Issue: elixir-lang/elixir#13974

Instead of using %Module{struct | ...} prefer pattern matching %Module{} = struct in the function head/case clause/etc. This should work better with the type system.

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

Find all occurrences with regex: %(\w+)\{(?<struct>\w+) \| and replace
them with %{$2 |
The syntax is being deprecated in Elixir 1.19 and emits warnings
…ccurrences

Use the regex %(\w+)\{[\r\n\s]*(?<struct>\w+)[\r\n\s]* \|
@IvanIvanoff IvanIvanoff requested a review from tspenov March 10, 2025 15:22
@IvanIvanoff IvanIvanoff merged commit d5ea973 into master Mar 11, 2025
4 checks passed
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.

1 participant