diff options
| -rw-r--r-- | source/slang/slang-check-overload.cpp | 36 | ||||
| -rw-r--r-- | source/slang/slang-check-type.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 2 | ||||
| -rw-r--r-- | tests/bugs/static-method.slang | 34 | ||||
| -rw-r--r-- | tests/bugs/static-method.slang.expected.txt | 4 |
5 files changed, 56 insertions, 22 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 92d390bf0..0cad2875a 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -849,25 +849,11 @@ namespace Slang } void SemanticsVisitor::AddFuncOverloadCandidate( - RefPtr<FuncType> /*funcType*/, - OverloadResolveContext& /*context*/) + RefPtr<FuncType> funcType, + OverloadResolveContext& context) { -#if 0 - if (funcType->decl) - { - AddFuncOverloadCandidate(funcType->decl, context); - } - else if (funcType->Func) - { - AddFuncOverloadCandidate(funcType->Func->SyntaxNode, context); - } - else if (funcType->Component) - { - AddComponentFuncOverloadCandidate(funcType->Component, context); - } -#else - throw "unimplemented"; -#endif + SLANG_UNUSED(funcType); + getSink()->diagnose(context.loc, Diagnostics::unimplemented, "call on expression of function type"); } void SemanticsVisitor::AddCtorOverloadCandidate( @@ -1093,9 +1079,19 @@ namespace Slang } void SemanticsVisitor::AddOverloadCandidates( - RefPtr<Expr> funcExpr, - OverloadResolveContext& context) + RefPtr<Expr> funcExpr, + OverloadResolveContext& context) { + // A call of the form `(<something>)(<args>)` should be + // resolved as if the user wrote `<something>(<args>)`, + // so that we avoid introducing intermediate expressions + // of function type in cases where they are not needed. + // + while(auto parenExpr = as<ParenExpr>(funcExpr)) + { + funcExpr = parenExpr->base; + } + auto funcExprType = funcExpr->type; if (auto declRefExpr = as<DeclRefExpr>(funcExpr)) diff --git a/source/slang/slang-check-type.cpp b/source/slang/slang-check-type.cpp index 68e14c462..f0ec54061 100644 --- a/source/slang/slang-check-type.cpp +++ b/source/slang/slang-check-type.cpp @@ -86,7 +86,7 @@ namespace Slang return expr; } - getSink()->diagnose(expr, Diagnostics::unimplemented, "expected a type"); + getSink()->diagnose(expr, Diagnostics::expectedAType, expr->type); return CreateErrorExpr(expr); } diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 2fbd373cc..a28bfe77e 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -252,7 +252,7 @@ DIAGNOSTIC(30051, Error, invalidValueForArgument, "invalid value for argument '$ DIAGNOSTIC(30052, Error, invalidSwizzleExpr, "invalid swizzle pattern '$0' on type '$1'") DIAGNOSTIC(30043, Error, getStringHashRequiresStringLiteral, "getStringHash parameter can only accept a string literal") -DIAGNOSTIC(30060, Error, expectedAType, "expected a type got a '$0'") +DIAGNOSTIC(30060, Error, expectedAType, "expected a type, got a '$0'") DIAGNOSTIC(30100, Error, staticRefToNonStaticMember, "type '$0' cannot be used to refer to non-static member '$1'") diff --git a/tests/bugs/static-method.slang b/tests/bugs/static-method.slang new file mode 100644 index 000000000..dfb13b4a8 --- /dev/null +++ b/tests/bugs/static-method.slang @@ -0,0 +1,34 @@ +// static-method.slang + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute + +struct S +{ + static void doThing(in out int x, int y) + { + x += y; + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out +RWStructuredBuffer<int> outputBuffer : register(u0); + +int test(int t) +{ + // TODO: This case is currently being mis-handled by the parser +// S::doThing(t, 0x10); + + (S::doThing(t, 0x200)); + + (S::doThing)(t, 0x4000); + + return t; +} + +[numthreads(4)] +void computeMain(uint3 tid : SV_DispatchThreadID) +{ + int val = tid.x; + val = test(val); + outputBuffer[tid.x] = val; +} diff --git a/tests/bugs/static-method.slang.expected.txt b/tests/bugs/static-method.slang.expected.txt new file mode 100644 index 000000000..017c3bd20 --- /dev/null +++ b/tests/bugs/static-method.slang.expected.txt @@ -0,0 +1,4 @@ +4200 +4201 +4202 +4203 |
