Interface error improvements - #12594
Merged
Merged
Conversation
0x6e
force-pushed
the
nathan/interface-error-improvements
branch
from
July 22, 2026 16:00
6d2dab7 to
290ba4a
Compare
0x6e
marked this pull request as ready for review
July 22, 2026 17:00
LeonMatthes
reviewed
Jul 27, 2026
LeonMatthes
left a comment
Member
There was a problem hiding this comment.
Much better.
It would be great if we can show the actual code that needs to be added.
And I think we should keep the check errors on the implement statement instead of the implementation candidate (with potentially a note diagnostic on the candidate).
0x6e
force-pushed
the
nathan/interface-error-improvements
branch
from
July 27, 2026 10:52
290ba4a to
b1d9c5a
Compare
0x6e
force-pushed
the
nathan/interface-error-improvements
branch
2 times, most recently
from
July 27, 2026 18:17
468adca to
2c5e839
Compare
0x6e
force-pushed
the
nathan/interface-error-improvements
branch
from
July 27, 2026 20:10
2c5e839 to
796eb63
Compare
0x6e
force-pushed
the
nathan/interface-error-improvements
branch
from
July 28, 2026 09:10
796eb63 to
ccc102e
Compare
LeonMatthes
approved these changes
Jul 28, 2026
LeonMatthes
left a comment
Member
There was a problem hiding this comment.
This is definitely an improvement.
I left a few more ideas for further refinement. As discussed, these can be done as another follow-up.
0x6e
force-pushed
the
nathan/interface-error-improvements
branch
2 times, most recently
from
July 29, 2026 14:56
2031621 to
097664a
Compare
Reorganise the interface syntax tests (17 -> 9 files) around the compiler's validation stages so every diagnostic is asserted exactly once: declaration-body rules, interface/target resolution, self-implementation conformance, child delegation, cross-statement conflicts and parser-level grammar errors, keeping the two regression guards untouched. Drop the runtime test that duplicated implements_defaults. The child-forward "Cannot override binding" branch was unreachable - a pre-existing binding for an interface member is always intercepted by the earlier base-conflict or declaration-conflict checks - so replace it with a debug_assert. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The `uses` keyword has been replaced with the `implement` statement. Remove the old language from the syntax errors.
Rewrite the diagnostics emitted by `property_matches_interface` so that a mismatch between a component's API and an implemented interface is described precisely — the member's kind (property / callback / function), its visibility, and its purity. Multiple mismatches on a single member are presented as a multi-line list.
…gnostic Rather than emitting a error for every issue with a child-implement statement, consolidate them into one error with a list of issues.
… diagnostic for the `implement` statement Rather than emitting an error per conflict consolidate them all into a single error with a list of conflicts.
…a single diagnostic for the `implement` statement Rather than emitting an error per conflict consolidate them all into a single error with a list of conflicts. This function may still emit other diagnostics where the error source is not the `implement` statement.
Re-use the `missing_type_description` lambda to describe a missing property or callback in `validate_interface_member_implementation`.
Rather than saying "Cannot implement 'Interface'" we shorten it to "'Interface' error." followed by the list of conflicts. This is less verbose, doesn't mention the `implement` keyword where it is not the cause of the error and is just a bit nicer to read.
Remove `interfaces::validate_function_implementations` and rename `interfaces::validate_properties_and_callbacks` to `validate_self_implement_statements`. The new function no longer filters our function declarations, allowing us to use the same checking code and errors for all interface API.
…rface function implementation The langtype::Function implementation of PartialEq means that the compiler would emit an error if the implementation of an interface did not have exactly matching parameter names. We do not require this to satisfy interface API, so introduce our own comparison function for langtype::Type.
…don't match For example, `public` or `protected` function visibility doesn't make much sense in a property context (expects `in`, `out`, `in-out`). In this case, we emit the full type that the interface expects so that the user can get it right in one iteration.
Improve the parsing and compiler error to make it clear that interface inheritance is not supported (yet).
Add a syntax test to verify that `@rust-attr` does not support annotating interfaces.
Interface errors that occur due to a missing member, or a member being fully the wrong type (e.g. property instead of callback) now print the required Slint code.
Add a generic note to the unsatisfactory statement. In the future we can make this more specific.
Before we were emitting notes before the relevant errors which was not
very useful when looking at `slint-compiler` output. Now we emit the
notes after the error, giving us more understandable compiler output:
```
error: Cannot implement 'ValidInterface'.
- 'reset' must be a 'public function() -> void' (found a 'int' property)
- 'speak' must be a 'callback() -> void' (found a 'int' property)
- 'value' must be an in-out 'int' property (found a 'callback() -> void')
--> internal/compiler/tests/syntax/interfaces/implement_self.slint:255:15
|
255 | implement ValidInterface <=> self;
| ^^^^^^^^^^^^^^^
note: 'reset' does not satisfy 'ValidInterface'
--> internal/compiler/tests/syntax/interfaces/implement_self.slint:262:5
|
262 | in-out property <int> reset;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: 'speak' does not satisfy 'ValidInterface'
--> internal/compiler/tests/syntax/interfaces/implement_self.slint:260:5
|
260 | in-out property <int> speak;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: 'value' does not satisfy 'ValidInterface'
--> internal/compiler/tests/syntax/interfaces/implement_self.slint:258:5
|
258 | callback value();
| ^^^^^^^^^^^^^^^^^
```
…ing uses Verify that the new `implement` keyword doesn't break existing uses of the name "implement" for properties/callback/functions/etc.
0x6e
force-pushed
the
nathan/interface-error-improvements
branch
from
July 29, 2026 17:02
097664a to
b7ae663
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reorganise the interface syntax tests (17 -> 9 files) around the compiler's validation stages so every diagnostic is asserted exactly once: declaration-body rules, interface/target resolution, self-implementation conformance, child delegation, cross-statement conflicts and parser-level grammar errors, keeping the two regression guards untouched. Drop the runtime test that duplicated implements_defaults.
We then iterated through the various errors to:
This resulted in us being able to remove
interfaces::validate_function_implementationsand renameinterfaces::validate_properties_and_callbackstointerfaces::validate_self_implement_statementswhich no longer filters out function declarations.Relates to #1870.
Stack created with GitHub Stacks CLI • Give Feedback 💬