fix: resolve Elixir 1.19 typing violations and Inspect regression#81
Merged
Conversation
Elixir 1.19's stricter typing rejects `%X{var | field: ...}` updates when
`var` is bound from a `dynamic()` source (e.g. `Map.fetch!/2`,
function-arg pattern that doesn't pin the struct). Per the compiler's
hint, narrow each binding to the expected struct (`%X{} = var = ...` or
the function head pattern) and switch the update to map-update syntax.
Also fix the `MultiSet`'s `Inspect` implementation: `concat/2` no longer
accepts the doc shape returned by `Inspect.List.inspect/2` in Elixir
1.19.5. Use `to_doc/2` instead, which is the standard pattern for
embedding inspectable values.
Sites changed:
- `expression.ex` — 8 `%Scope{...}` updates in `analyse_node/2`
(parameter-pattern fix in each clause).
- `validators.ex` — `%ColouredPetriNet{...}` updates in `run/1`'s `with`.
- `enactment.ex` — `%Snapshot{...}` in `catchup_snapshot/2` and
`%Workitem{...}` updates in `apply_calibration/1` and
`start_workitems/2`.
- `workitem_consumption.ex` — `%Marking{...}` update in
`consume_tokens/2`.
- `multi_set.ex` — `Inspect.List.inspect/2` → `to_doc/2`.
Production behavior is unchanged — the new `%X{} = var` runtime guards
preserve the same struct-enforcement semantics. CI on Elixir 1.17.3 was
already green; this PR makes the local dev env on Elixir 1.19.5 green
too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Local Elixir 1.19.5 fails
mix compile --warnings-as-errorson `%X{var | field: ...}` struct updates where `var` is bound from a `dynamic()` source. CI on 1.17.3 is unaffected, but local dev breaks. Also the `MultiSet` `Inspect` impl regresses on 1.19.5: `Inspect.Algebra.concat/2` no longer accepts the doc shape returned by `Inspect.List.inspect/2`.Per the compiler hints, narrow each affected binding (`%X{} = var`) and switch updates to map-update syntax. Replace `Inspect.List.inspect/2` with `to_doc/2` in `MultiSet`'s `Inspect` impl.
Sites changed
Production behavior is unchanged — the new `%X{} = var` runtime guards preserve the same struct-enforcement semantics.
Test plan
🤖 Generated with Claude Code