Skip to content

Fix TypeError in IRVisitor when expressions are undefined due to parse errors#1

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-typeerror-in-irvisitor
Draft

Fix TypeError in IRVisitor when expressions are undefined due to parse errors#1
Copilot wants to merge 2 commits intomainfrom
copilot/fix-typeerror-in-irvisitor

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 12, 2025

  • I have read and I understand the Note on AI-assisted contributions
  • Changes manually tested locally and confirmed to work as described
    (including screenshots is helpful)
  • Tests added for any new code
  • Documentation added for any new functionality
  • Entries added to the respective CHANGELOG.md for any new functionality

Description

The IRVisitor crashed with TypeError: Cannot read properties of undefined (reading 'kind') when encountering malformed IR from parse errors. The visitor unconditionally called walkExpression() on fields that can be undefined.

Changes

quint/src/ir/IRVisitor.ts

  • Added null checks before walkExpression() calls in three locations:
    • OpDef.expr (line 381)
    • Assume.assumption (line 402)
    • Instance.overrides expressions (line 303)

quint/test/ir/IRVisitor.test.ts

  • Added test suite "handles malformed IR gracefully" with coverage for all three cases

Example

Before this change, malformed IR like:

const malformedDef = {
  kind: 'def',
  name: 'badDef',
  expr: undefined  // Can happen with parse errors
}
walkDefinition(visitor, malformedDef) // TypeError

Now handles gracefully by skipping the undefined expression walk.

Original prompt

Eu gostaria que investigasse o seguinte bug e criasse um fiz em inglês mesmo

{
Typecheck Output:

TypeError: Cannot read properties of undefined (reading 'kind')
at walkExpression (/opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/ir/IRVisitor.js:322:18)
at walkDefinition (/opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/ir/IRVisitor.js:302:13)
at walkDeclaration (/opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/ir/IRVisitor.js:201:13)
at /opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/ir/IRVisitor.js:55:46
at Array.forEach ()
at walkModule (/opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/ir/IRVisitor.js:55:30)
at NameResolver.enterModule (/opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/names/resolver.js:68:36)
at walkModule (/opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/ir/IRVisitor.js:53:17)
at /opt/homebrew/Cellar/quint/0.29.1/libexec/lib/node_modules/@informalsystems/quint/dist/src/names/resolver.js:30:36
at Array.forEach ()


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Add defensive guards in walkDefinition and walkDeclaration to handle
undefined expressions that can occur during parse errors. This prevents
the "Cannot read properties of undefined (reading 'kind')" error.

- Add null checks before calling walkExpression for def.expr
- Add null checks before calling walkExpression for def.assumption
- Add null checks before calling walkExpression for instance overrides
- Add comprehensive test cases for all three scenarios

Co-authored-by: roehst <21047691+roehst@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TypeError when reading properties of undefined in IRVisitor Fix TypeError in IRVisitor when expressions are undefined due to parse errors Dec 12, 2025
Copilot AI requested a review from roehst December 12, 2025 11:10
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