Skip to content

feat(lint): add assert-state-change#14784

Open
mablr wants to merge 1 commit into
masterfrom
mablr/assert-state-change_lint
Open

feat(lint): add assert-state-change#14784
mablr wants to merge 1 commit into
masterfrom
mablr/assert-state-change_lint

Conversation

@mablr
Copy link
Copy Markdown
Collaborator

@mablr mablr commented May 15, 2026

Motivation

Add assert-state-change lint to detect state-modifying expressions inside assert() arguments.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Detects state-modifying expressions inside `assert()` calls.
Copy link
Copy Markdown
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One remaining behavior gap before this lands.

find_state_change(hir, inner)
}

ExprKind::Call(callee, args, named_args) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only treats push/pop and bare identifier functions as mutating calls. External/member calls inside assert, e.g. assert(this.deposit()), assert(payable(to).send(1 ether)), or a token/interface call with side effects, fall through to recursion and are not reported. Since the lint is documented as catching function calls that write state, can we either detect mutating external/member calls or narrow the docs/tests to the intended scope?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants