From 2275e18fc052239fe67f3fda68252ad92bb83ca9 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Thu, 15 May 2025 01:55:17 +0000 Subject: Do not print errors in _coerce when "JustTrying". (#7064) * Do not print errors in _coerce when "JustTrying". While figuring out which generic-overload works best, `_coerce()` is printing errors and Slang compilation terminates prematurely. When `TryCheckGenericOverloadCandidateTypes()` is calling `_coerce()` in "JustTrying" mode, the error messages should be snoozed. The following logic shows the intention of how to silence the error messages, but the chain of `sink` was broken in the middle and `_coerce()` was using `getSink()` from the SemanticVisitor. val = ExtractGenericArgInteger( arg, getType(m_astBuilder, valParamRef), context.mode == OverloadResolveContext::Mode::JustTrying ? nullptr : getSink()); * Use tempSink when available. --- .../generics/generic-overload.slang | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/language-feature/generics/generic-overload.slang (limited to 'tests') diff --git a/tests/language-feature/generics/generic-overload.slang b/tests/language-feature/generics/generic-overload.slang new file mode 100644 index 000000000..a5ce3ae8f --- /dev/null +++ b/tests/language-feature/generics/generic-overload.slang @@ -0,0 +1,37 @@ +//TEST(compute):SIMPLE(filecheck=CHECK_EXPLICIT): -target spirv-asm -entry computeMain -stage compute -DEXPLICIT +//TEST(compute):SIMPLE(filecheck=CHECK_OVERLOAD): -target spirv-asm -entry computeMain -stage compute -DOVERLOAD + +enum CoopMatMatrixLayout +{ + RowMajor = 0, + ColumnMajor = 1, +}; + +int Load(int inVal) +{ + return int(inVal % 10); +} + +#if !defined(EXPLICIT) +int Load(int inVal, int inVal2) +{ + return Load(inVal); +} +#endif + +[Shader("compute")] +[NumThreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + +#if defined(EXPLICIT) + //CHECK_EXPLICIT: error 30019: expected an expression of type 'CoopMatMatrixLayout', got 'int' + //CHECK_EXPLICIT: note: explicit conversion from 'int' to 'CoopMatMatrixLayout' is possible + int outVal = Load<0>(tid); + +#elif defined(OVERLOAD) + //CHECK_OVERLOAD-NOT: error {{[1-9][0-9]*}} + int outVal = Load(tid); +#endif +} -- cgit v1.2.3