Update error messages to say initializer
The spec talks about initializers for `var`, `const` and `let` constructs. The parser was emitting `constructor`. This CL updates the terminology to match the spec in order to make searching for answers easier. Bug: tint:1600 Change-Id: Ic135856ba9afbfd2580b648d8f2e402059bac8be Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96906 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
05288f6cff
commit
87254ff58e
|
@ -562,7 +562,7 @@ Maybe<const ast::Variable*> ParserImpl::global_variable_decl(ast::AttributeList&
|
|||
decl->type, // type
|
||||
decl->storage_class, // storage class
|
||||
decl->access, // access control
|
||||
initalizer, // constructor
|
||||
initalizer, // initializer
|
||||
std::move(attrs)); // attributes
|
||||
}
|
||||
|
||||
|
@ -619,20 +619,20 @@ Maybe<const ast::Variable*> ParserImpl::global_constant_decl(ast::AttributeList&
|
|||
return create<ast::Const>(decl->source, // source
|
||||
builder_.Symbols().Register(decl->name), // symbol
|
||||
decl->type, // type
|
||||
initializer, // constructor
|
||||
initializer, // initializer
|
||||
std::move(attrs)); // attributes
|
||||
}
|
||||
if (is_overridable) {
|
||||
return create<ast::Override>(decl->source, // source
|
||||
builder_.Symbols().Register(decl->name), // symbol
|
||||
decl->type, // type
|
||||
initializer, // constructor
|
||||
initializer, // initializer
|
||||
std::move(attrs)); // attributes
|
||||
}
|
||||
return create<ast::Const>(decl->source, // source
|
||||
builder_.Symbols().Register(decl->name), // symbol
|
||||
decl->type, // type
|
||||
initializer, // constructor
|
||||
initializer, // initializer
|
||||
std::move(attrs)); // attributes
|
||||
}
|
||||
|
||||
|
@ -1803,18 +1803,18 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_stmt() {
|
|||
return Failure::kErrored;
|
||||
}
|
||||
|
||||
auto constructor = logical_or_expression();
|
||||
if (constructor.errored) {
|
||||
auto initializer = logical_or_expression();
|
||||
if (initializer.errored) {
|
||||
return Failure::kErrored;
|
||||
}
|
||||
if (!constructor.matched) {
|
||||
return add_error(peek(), "missing constructor for 'const' declaration");
|
||||
if (!initializer.matched) {
|
||||
return add_error(peek(), "missing initializer for 'const' declaration");
|
||||
}
|
||||
|
||||
auto* const_ = create<ast::Const>(decl->source, // source
|
||||
builder_.Symbols().Register(decl->name), // symbol
|
||||
decl->type, // type
|
||||
constructor.value, // constructor
|
||||
initializer.value, // initializer
|
||||
ast::AttributeList{}); // attributes
|
||||
|
||||
return create<ast::VariableDeclStatement>(decl->source, const_);
|
||||
|
@ -1831,18 +1831,18 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_stmt() {
|
|||
return Failure::kErrored;
|
||||
}
|
||||
|
||||
auto constructor = logical_or_expression();
|
||||
if (constructor.errored) {
|
||||
auto initializer = logical_or_expression();
|
||||
if (initializer.errored) {
|
||||
return Failure::kErrored;
|
||||
}
|
||||
if (!constructor.matched) {
|
||||
return add_error(peek(), "missing constructor for 'let' declaration");
|
||||
if (!initializer.matched) {
|
||||
return add_error(peek(), "missing initializer for 'let' declaration");
|
||||
}
|
||||
|
||||
auto* let = create<ast::Let>(decl->source, // source
|
||||
builder_.Symbols().Register(decl->name), // symbol
|
||||
decl->type, // type
|
||||
constructor.value, // constructor
|
||||
initializer.value, // initializer
|
||||
ast::AttributeList{}); // attributes
|
||||
|
||||
return create<ast::VariableDeclStatement>(decl->source, let);
|
||||
|
@ -1856,17 +1856,17 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_stmt() {
|
|||
return Failure::kNoMatch;
|
||||
}
|
||||
|
||||
const ast::Expression* constructor = nullptr;
|
||||
const ast::Expression* initializer = nullptr;
|
||||
if (match(Token::Type::kEqual)) {
|
||||
auto constructor_expr = logical_or_expression();
|
||||
if (constructor_expr.errored) {
|
||||
auto initializer_expr = logical_or_expression();
|
||||
if (initializer_expr.errored) {
|
||||
return Failure::kErrored;
|
||||
}
|
||||
if (!constructor_expr.matched) {
|
||||
return add_error(peek(), "missing constructor for 'var' declaration");
|
||||
if (!initializer_expr.matched) {
|
||||
return add_error(peek(), "missing initializer for 'var' declaration");
|
||||
}
|
||||
|
||||
constructor = constructor_expr.value;
|
||||
initializer = initializer_expr.value;
|
||||
}
|
||||
|
||||
auto* var = create<ast::Var>(decl->source, // source
|
||||
|
@ -1874,7 +1874,7 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_stmt() {
|
|||
decl->type, // type
|
||||
decl->storage_class, // storage class
|
||||
decl->access, // access control
|
||||
constructor, // constructor
|
||||
initializer, // initializer
|
||||
ast::AttributeList{}); // attributes
|
||||
|
||||
return create<ast::VariableDeclStatement>(var->source, var);
|
||||
|
|
|
@ -220,7 +220,7 @@ fn f() { let a : i32; }
|
|||
|
||||
TEST_F(ParserImplErrorTest, ConstVarStmtMissingConstructor) {
|
||||
EXPECT("fn f() { let a : i32 = >; }",
|
||||
R"(test.wgsl:1:24 error: missing constructor for 'let' declaration
|
||||
R"(test.wgsl:1:24 error: missing initializer for 'let' declaration
|
||||
fn f() { let a : i32 = >; }
|
||||
^
|
||||
)");
|
||||
|
@ -1284,7 +1284,7 @@ fn f() { var a : u32 }
|
|||
|
||||
TEST_F(ParserImplErrorTest, VarStmtInvalidAssignment) {
|
||||
EXPECT("fn f() { var a : u32 = >; }",
|
||||
R"(test.wgsl:1:24 error: missing constructor for 'var' declaration
|
||||
R"(test.wgsl:1:24 error: missing initializer for 'var' declaration
|
||||
fn f() { var a : u32 = >; }
|
||||
^
|
||||
)");
|
||||
|
|
|
@ -114,7 +114,7 @@ TEST_F(ParserImplTest, Statement_Variable_Invalid) {
|
|||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
EXPECT_EQ(p->error(), "1:14: missing constructor for 'var' declaration");
|
||||
EXPECT_EQ(p->error(), "1:14: missing initializer for 'var' declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Variable_MissingSemicolon) {
|
||||
|
|
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ConstructorInvalid) {
|
|||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:15: missing constructor for 'var' declaration");
|
||||
EXPECT_EQ(p->error(), "1:15: missing initializer for 'var' declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit) {
|
||||
|
@ -170,7 +170,7 @@ TEST_F(ParserImplTest, VariableStmt_Let_MissingConstructor) {
|
|||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:14: missing constructor for 'let' declaration");
|
||||
EXPECT_EQ(p->error(), "1:14: missing initializer for 'let' declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Let_InvalidConstructor) {
|
||||
|
@ -180,7 +180,7 @@ TEST_F(ParserImplTest, VariableStmt_Let_InvalidConstructor) {
|
|||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:15: missing constructor for 'let' declaration");
|
||||
EXPECT_EQ(p->error(), "1:15: missing initializer for 'let' declaration");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue