Add unit test to check LHS is not an intrinsic function name
Identifiers cannot be assigned. Bug: tint:203 Change-Id: Ibe34749264024b690d8a8bd271304f425a2688ed Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54080 Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
This commit is contained in:
parent
b5508fdcb5
commit
06e2e5c2f7
|
@ -86,6 +86,13 @@ TEST_F(ParserImplErrorTest, AssignmentStmtMissingSemicolon) {
|
|||
" ^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, AssignmentStmtInvalidLHS_IntrinsicFunctionName) {
|
||||
EXPECT("normalize = 5;",
|
||||
"test.wgsl:1:1 error: statement found outside of function body\n"
|
||||
"normalize = 5;\n"
|
||||
"^^^^^^^^^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, AssignmentStmtInvalidRHS) {
|
||||
EXPECT("fn f() { a = >; }",
|
||||
"test.wgsl:1:14 error: unable to parse right side of assignment\n"
|
||||
|
|
|
@ -141,6 +141,19 @@ TEST_F(ResolverValidationTest, Expr_DontCall_Intrinsic) {
|
|||
EXPECT_EQ(r()->error(), "3:8 error: missing '(' for intrinsic call");
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest,
|
||||
AssignmentStmt_InvalidLHS_IntrinsicFunctionName) {
|
||||
// normalize = 2;
|
||||
|
||||
auto* lhs = Expr(Source{{12, 34}}, "normalize");
|
||||
auto* rhs = Expr(2);
|
||||
auto* assign = Assign(lhs, rhs);
|
||||
WrapInFunction(assign);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: missing '(' for intrinsic call");
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, UsingUndefinedVariable_Fail) {
|
||||
// b = 2;
|
||||
|
||||
|
|
Loading…
Reference in New Issue