Fix dialyzer opaqueness warnings on module attrs in OTP28#14755
Fix dialyzer opaqueness warnings on module attrs in OTP28#14755sabiwara merged 2 commits intoelixir-lang:mainfrom
Conversation
|
I wonder if instead we should do |
I thought about it too, yeah it sounds good! |
| * `:generated` - (since v1.19.0) Whether the AST should be considered as generated | ||
| by the compiler or not. This means the compiler and tools like Dialyzer may not | ||
| emit certain warnings. |
There was a problem hiding this comment.
Basically the same as https://hexdocs.pm/elixir/1.19.0-rc.0/Macro.html#t:metadata/0
| {caller, meta, args} when generated and is_list(meta) -> | ||
| {caller, [generated: true] ++ meta, args} |
There was a problem hiding this comment.
Should we wrap with a __block__ for other ASTs?
It feels a bit too much, we shouldn't need it for this use case and quote doesn't do it either.
There was a problem hiding this comment.
I think there is no need, yeah.
fd96bab to
c351990
Compare
* Mark module attributes as generated in case they contain opaque terms * Add and use Macro.escape(ast, generated: true)
|
Backported ✅ |
| nodes. Note this option changes the semantics of escaped code and | ||
| it should only be used when escaping ASTs. Defaults to `false`. | ||
|
|
||
| * `:generated` - (since v1.19.0) Whether the AST should be considered as generated |
There was a problem hiding this comment.
@sabiwara the new options should be included in escape_opts type
There was a problem hiding this comment.
Wooops, thank you for catching this one ! 💜
Will fix
There was a problem hiding this comment.
Was this backported to Elixir 1.19? It still appears to be happening on elixir 1.19.5 and otp 28.3.2
There was a problem hiding this comment.
@sabiwara i'm still having the issue at Elixir 1.19.5 with otp 28.4.1. Should I upgrate to recent versions?
There was a problem hiding this comment.
@itsGabriel @hez this PR has been backported to 1.19.5, but wasn't enough to fix all instances of #14837 due to the way OTP28 contract checking ignores generated annotations.
An example of this is:
@map_set MapSet.new(1..10)
@spec contract_violation :: MapSet.t()
def contract_violation, do: @map_setraises a contract_with_opaque on 1.19.5 / OTP28:
file:line:contract_with_opaque
The @spec for Repro.contract/0 has an opaque
subtype %MapSet{:map => MapSet.internal(_)} which is violated by the success typing.
We ended up removing @opaque from MapSet or URI types, but this part was done after 1.19.5 and hasn't been backported.
The 1.20 rc should fix this, but until the stable release, you can suppress it by temporarily adding @dialyzer {:no_opaque, [fun: arity]} (or just @dialyzer :no_opaque).
Marks module attributes as generated in case they contain opaque terms
Close #14750
To be backported to 1.19