Skip to content

Prove the values the non-null assertions asserted, where a test or loop form can - #115

Merged
rostislavrotaru merged 3 commits into
mainfrom
dev1/96-non-null-assertions
Nov 15, 2026
Merged

rostislavrotaru merged 3 commits into
mainfrom
dev1/96-non-null-assertions

Conversation

@rostislavrotaru

@rostislavrotaru rostislavrotaru commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Issue: #96

Removes the non-null assertions that a loop form, destructuring or Assert.isDefined in a test can prove. #96 stays open for the sites below, which wait on a shared helper.

Changed

  • noldova.context.testing/src/resources.ts, services/reporting/test-console-reporter.ts: the progress line is built from its text and a count of dots, so no array read needs !. The output is unchanged.
  • parsers.typescript/tests/conformance/conformance-cases.test.ts, parsers.regex/tests/conformance/conformance-cases.test.ts: Assert.isDefined on the case's record.
  • typescript-for-in-or-of-statement.node.extensions.ts: destructures the first two declarations instead of reading children[0]!.
  • typescript-binding-element.node.extensions.ts: the rest-initializer check tests equalsNode, which every construction sets together with initializerNode, so its span needs no !.
  • parsers.typescript/tests/fixtures/typescript-diagnostics.fixture.ts: Assert.isDefined on a related location, like the fixture's other location reads.
  • parsers.typescript/src/api/index.d.ts: the TypeScriptTypeOperatorNode example compares against the operand it built, instead of type.typeNode!.

Left for the helper (12 sites)

Production code has no Assert.isDefined, and an inline guard on these would be unreachable, which fails the 100% coverage gate.

  • Binary searches: collections/src/services/binary-search.service.ts:16, parsers.typescript/src/models/typescript-region-set.ts:32 and :38, testing/src/services/coverage/file-coverage-analyzer.ts:176.
  • codePointAt on an offset already in range: parsers/src/services/source.reader.ts:59, parsers.regex/.../regex-named-capturing-group.parser.ts:45.
  • typescript-expression-with-type-arguments.node.extensions.ts:37 (typeArgumentListNode: only the expression parsers reach it, and they always set a list).
  • typescript-block.node.extensions.ts:20 (openBraceNode): a missing block is never a statement or a node's first child, and no test I found reaches its first token.
  • Diagnostic.location (4 sites, 7 reads): parsers.typescript/src/services/typescript.parser.ts:66, :77, :108 (four reads in one comparison) and services/parsers/source.parser.ts:78. The syntax diagnostics come from the exported DiagnosticCollector as Diagnostic[], so an internal located type would need the same proof or an API change.

Agent: DEV1 (developer)
Agent-Model: Anthropic Opus 5.5, Medium

- The console reporter draws its progress frame from a text and a dot
  count rather than reading an array by index.
- The two conformance tests check that their case's record exists with
  Assert.isDefined.
- The for-in/of check destructures its first two declarations once,
  where it already returned for an empty list.
- The rest-initializer check tests the binding element's equals node,
  which the parser sets exactly when it sets the initializer.

Part of #96.

Agent: DEV1 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
Agent: DEV1 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
@rostislavrotaru rostislavrotaru self-assigned this Nov 15, 2026
Agent: DEV1 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
@rostislavrotaru
rostislavrotaru marked this pull request as ready for review November 15, 2026 01:47

@rostislavrotaru rostislavrotaru left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed: #115 at e3dd4f7
Verdict: Approve
Findings: 0 Should fix, 0 Low, as line comments
Why it's right: seven non-null assertions are proved by their types with no hidden assertion or untested branch, no exported API changes, and the twelve sites left for the shared helper are named; #96 stays open for them.

Agent: LEAD (lead)
Agent-Model: Anthropic Opus 5.5, High

@rostislavrotaru
rostislavrotaru merged commit 97c349e into main Nov 15, 2026
30 checks passed
@rostislavrotaru
rostislavrotaru deleted the dev1/96-non-null-assertions branch November 15, 2026 01:55
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.

1 participant