Skip to content

feat: add return type and property type mismatch diagnostics#220

Draft
calebdw wants to merge 1 commit into
mainfrom
calebdw/push-mknwnlmknmok
Draft

feat: add return type and property type mismatch diagnostics#220
calebdw wants to merge 1 commit into
mainfrom
calebdw/push-mknwnlmknmok

Conversation

@calebdw

@calebdw calebdw commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Add two new diagnostic collectors to the type mismatch family:

  • type_mismatch_return: checks return statements against declared return types. Flags incompatible types, void functions returning values, and bare return; in non-void functions. Skips generators, abstract methods, mixed/untyped returns.

  • type_mismatch_property: checks $this->prop and self::$prop assignments against declared property types. Only plain = assignments; compound operators are skipped.

Both reuse the existing is_type_compatible() policy layer and resolve_expression_type() infrastructure. A unified collect_type_mismatch_diagnostics() entry point groups all three collectors (argument, return, property).

Closes #201

@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from 9cf394a to f48ba67 Compare July 10, 2026 13:59
@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 85.76233% with 127 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/diagnostics/return_type_errors.rs 88.11% 68 Missing ⚠️
src/diagnostics/property_type_errors.rs 82.60% 52 Missing ⚠️
src/analyse.rs 0.00% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@calebdw calebdw requested a review from AJenbo July 10, 2026 14:08
@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from f48ba67 to 272f9d5 Compare July 10, 2026 17:29
@AJenbo

AJenbo commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This is surfacing a bunch of false positives that we need to resolve first, aka merging after 0.9.0

@calebdw calebdw marked this pull request as draft July 10, 2026 17:42
@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch 2 times, most recently from 5eda8f3 to 7281dd8 Compare July 10, 2026 19:00
@calebdw

calebdw commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Can you post some examples of these false positives?

@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from 7281dd8 to 26c49fa Compare July 10, 2026 21:28
Add two new diagnostic collectors to the type mismatch family:

- type_mismatch_return: checks return statements against declared
  return types. Flags incompatible types, void functions returning
  values, and bare return; in non-void functions. Skips generators,
  abstract methods, mixed/untyped returns.

- type_mismatch_property: checks $this->prop and self::$prop
  assignments against declared property types. Only plain =
  assignments; compound operators are skipped.

Both reuse the existing is_type_compatible() policy layer and
resolve_expression_type() infrastructure. A unified
collect_type_mismatch_diagnostics() entry point groups all three
collectors (argument, return, property).

Closes #201
@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from 26c49fa to e645de0 Compare July 10, 2026 22:20
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.

emit diagnostic for invalid code

3 participants