-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
When compiling my app, which uses sweet_xml 0.7.5, I get these warnings:
==> sweet_xml
Compiling 2 files (.ex)
warning: a struct for SweetXpath is expected on struct update:
%SweetXpath{xpath | namespaces: [{to_charlist(prefix), to_charlist(uri)} | xpath.namespaces]}
but got type:
dynamic()
where "xpath" was given the type:
# type: dynamic()
# from: lib/sweet_xml.ex:245:21
xpath
when defining the variable "xpath", you must also pattern match on "%SweetXpath{}".
hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:
user = some_function()
%User{user | name: "John Doe"}
it is enough to write:
%User{} = user = some_function()
%{user | name: "John Doe"}
typing violation found at:
│
246 │ %SweetXpath{xpath | namespaces: [{to_charlist(prefix), to_charlist(uri)}
│ ~
│
└─ (sweet_xml 0.7.5) lib/sweet_xml.ex:246:5: SweetXml.add_namespace/3
Generated sweet_xml app
This is due to elixir now preferring that the struct update syntax include the struct name (or alternatively, that you pattern match using the struct name) so that the type checker can work on the struct. More details in the Changelog.
This is just a warning, there's no correctness issue. The benefits to fixing this would be:
- Silence the warnings when users of the library compile it.
- Benefit from the extra type safety of Elixir 1.19.
Metadata
Metadata
Assignees
Labels
No labels