summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-07-24 00:47:26 -0700
committerGitHub <noreply@github.com>2025-07-24 07:47:26 +0000
commit2d23a962766a97cbb11bcee5483a66aec923da49 (patch)
tree78e8475ff5f60e5a97b71a86467040c69ed56a90 /tests/diagnostics
parentf78d7528fdcbd4d1825660356927ab33035377b7 (diff)
Fix confusing error messages for interface return type mismatches (#7854)
* Initial plan * Add improved diagnostic for interface return type mismatches Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Complete fix for interface return type mismatch error reporting Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Move diagnostic to synthesis phase for better interface return type mismatch errors Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove extraneous test file and update .gitignore Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add diagnostic test for interface return type mismatch and apply formatting Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address feedback: restore whitespace and use filecheck for diagnostic test Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix logic error in return type mismatch detection Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove unnecessary flag by using out parameter for diagnostic tracking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Refactor witness synthesis failure reporting to use structured approach Replace ad-hoc `outSpecificDiagnosticEmitted` parameter with `WitnessSynthesisFailureReason` enum and `MethodWitnessSynthesisFailureDetails` struct as requested in code review. This provides: - Clear taxonomy of failure reasons (General, MethodResultTypeMismatch, MethodParameterMismatch) - Centralized diagnostic emission in findWitnessForInterfaceRequirement - Better extensibility for future failure types - Improved maintainability by removing state tracking flags The return type mismatch diagnostic continues to work correctly, showing error 38106 with precise location information. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove unused MethodParameterMismatch enum and duplicate code Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove redundant requiredMethod field from MethodWitnessSynthesisFailureDetails Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address feedback: add outFailureDetails guard and remove unnecessary hasReturnTypeError variable Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix regression: restore original diagnostic message for mutating method mismatch Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix. * Fix. * Remove `innerSink`. * Print candidates considered for interface match upon error. * Fix tests. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/diagnostics')
-rw-r--r--tests/diagnostics/interfaces/return-type-mismatch.slang20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/diagnostics/interfaces/return-type-mismatch.slang b/tests/diagnostics/interfaces/return-type-mismatch.slang
new file mode 100644
index 000000000..244f2f18e
--- /dev/null
+++ b/tests/diagnostics/interfaces/return-type-mismatch.slang
@@ -0,0 +1,20 @@
+// return-type-mismatch.slang
+
+//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
+
+enum LobeTypes : uint32_t { None = 0, Diffuse = 1 }
+
+interface IMaterialInstance {
+ LobeTypes get_lobe_types();
+}
+
+struct Broken : IMaterialInstance {
+ // CHECK: ([[# @LINE+1]]): error 38106:
+ uint get_lobe_types() { return LobeTypes::Diffuse; }
+}
+
+int test()
+{
+ Broken b;
+ return 0;
+} \ No newline at end of file