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

Suppress warnings in elixir 1.17 #109

Merged
merged 3 commits into from
Jun 14, 2024
Merged

Conversation

k-asm
Copy link
Contributor

@k-asm k-asm commented Jun 13, 2024

Fix warnings in elixir 1.17 like:

  • using map.field notation (without parentheses) to invoke function Test.User.__struct__() is deprecated, you must add parentheses instead: remote.function()
  • single-quoted strings represent charlists. Use ~c"" if you indeed want a charlist or use "" instead

k-asm added 2 commits June 13, 2024 17:55
like: using map.field notation (without parentheses) to invoke function Test.User.__struct__() is deprecated, you must add parentheses instead: remote.function()
warning: single-quoted strings represent charlists. Use ~c"" if you indeed want a charlist or use "" instead
@bernardd
Copy link
Contributor

Thanks @k-asm! Looks like some earlier versions of OTP might not have the correct typing specs to allow a binary rather than a charlist as the first argument of :gen_tcp.connect. Probably easier to just change it to a charlist.

With the __struct__ change, obviously it works but I'm just trying to understand it - do you know why __struct__() is suddenly a function? I was always under the impression that it was just a member in which case it shouldn't need the parentheses.

@k-asm
Copy link
Contributor Author

k-asm commented Jun 14, 2024

Thanks for responding.

My understanding is that __struct__ is both as a member and automatically defined functions as __struct__/0 and __struct__/1 via defstruct.

I was diving into some older Elixir docs, and saw in the v1.10 docs (for example): "To define a struct, a developer must define both __struct__/0 and __struct__/1 functions. defstruct/1 is a convenience macro which defines such functions with some conveniences."

https://hexdocs.pm/elixir/1.10.4/Kernel.html#defstruct/1

@bernardd
Copy link
Contributor

Ah, right you are. Doesn't quite explain why it won't let us just use the member rather than calling the function, but I guess it doesn't matter either way. Thanks again :)

@bernardd bernardd merged commit a5cb6b4 into ex-aws:main Jun 14, 2024
5 checks passed
@k-asm k-asm deleted the work/suppress-warnings branch June 14, 2024 05:54
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.

2 participants