Skip to content

fix: remove redundant type checks flagged by compiler#138

Merged
mhanberg merged 2 commits into
elixir-tools:mainfrom
gilbertwong96:fix/remove-redundant-type-checks
Jul 2, 2026
Merged

fix: remove redundant type checks flagged by compiler#138
mhanberg merged 2 commits into
elixir-tools:mainfrom
gilbertwong96:fix/remove-redundant-type-checks

Conversation

@gilbertwong96

@gilbertwong96 gilbertwong96 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

The compiler emitted two warnings for checks that are always true or always false due to prior type narrowing.

In Spitfire.Env.expand/3, the :import clause re-checked is_atom(arg) inside a with despite the enclosing if is_atom(arg) do already narrowing arg to atom(). Dropped the redundant guard, matching the sibling :require clause.

In Spitfire.skip_call_args/2, the first cond clause (token == nil or token == :eof) already handles :eof, so the trailing token == :eof in the second clause compared disjoint types and was dead. Removed it.

- Drop redundant is_atom/1 in import clause (already guarded by outer if)
- Remove dead token == :eof in skip_call_args (already handled by prior clause)
@mhanberg

Copy link
Copy Markdown
Contributor

Please revert the 1.20/otp29 change.

The parser tests for equality against the core parser and that changes between versions so we only test against the latest version and I haven't made the updates for 1.20 yet.

@gilbertwong96 gilbertwong96 force-pushed the fix/remove-redundant-type-checks branch from 7848928 to 5bce7d8 Compare June 30, 2026 02:44
@mhanberg mhanberg merged commit 89ee841 into elixir-tools:main Jul 2, 2026
38 checks passed
@gilbertwong96 gilbertwong96 deleted the fix/remove-redundant-type-checks branch July 3, 2026 02:52
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