Revert "Fixed SkSL error reporting on array types"

This reverts commit 6e686b8b8b.

Reason for revert: After internal discussion, we established that nobody was actually sure why this had needed to be an error in the old parser in the first place, so there does not appear to be a reason to carry the behavior forward.

Original change's description:
> Fixed SkSL error reporting on array types
>
> The DSLParser was not reporting errors when the array type appeared
> before the variable name (float[2] x) as opposed to after (float x[2])
> in strict ES2 mode.
>
> Bug: skia:12410
>
> Change-Id: Ia388aa150f65916dc3ccc58f7680dbde0a636c5f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/491819
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

Bug: skia:12410
Change-Id: I355fd1ad89e2e64b0377be7672b7f3f824eebac8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/491996
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
This commit is contained in:
Ethan Nicholas 2022-01-06 16:52:34 +00:00 committed by SkCQ
parent 6e686b8b8b
commit 4cd3ae4009
5 changed files with 7 additions and 17 deletions

View File

@ -1,6 +1,4 @@
// Expect 3 errors
float[123] global;
// Expect 2 errors
void array_decl() { float[123] x; }

View File

@ -457,12 +457,6 @@ bool DSLParser::parseArrayDimensions(int line, DSLType* type) {
return true;
}
void DSLParser::checkArrayDimensions(int line, DSLType& type) {
if (type.isArray() && ThreadContext::Context().fConfig->strictES2Mode()) {
this->error(line, "array size must appear after variable name");
}
}
bool DSLParser::parseInitializer(int line, DSLExpression* initializer) {
if (this->checkNext(Token::Kind::TK_EQ)) {
DSLExpression value = this->assignmentExpression();
@ -481,7 +475,6 @@ void DSLParser::globalVarDeclarationEnd(PositionInfo pos, const dsl::DSLModifier
using namespace dsl;
int line = this->peek().fLine;
DSLType type = baseType;
this->checkArrayDimensions(line, type);
DSLExpression initializer;
if (!this->parseArrayDimensions(line, &type)) {
return;
@ -521,7 +514,6 @@ DSLStatement DSLParser::localVarDeclarationEnd(PositionInfo pos, const dsl::DSLM
using namespace dsl;
int line = this->peek().fLine;
DSLType type = baseType;
this->checkArrayDimensions(line, type);
DSLExpression initializer;
if (!this->parseArrayDimensions(line, &type)) {
return {};

View File

@ -153,8 +153,6 @@ private:
bool parseArrayDimensions(int line, dsl::DSLType* type);
void checkArrayDimensions(int line, dsl::DSLType& type);
bool parseInitializer(int line, dsl::DSLExpression* initializer);
void globalVarDeclarationEnd(PositionInfo position, const dsl::DSLModifiers& mods,

View File

@ -49,6 +49,10 @@ void VarDeclaration::ErrorCheck(const Context& context,
context.fErrors->error(line, "variables of type 'void' are not allowed");
return;
}
if (context.fConfig->strictES2Mode() && baseType->isArray()) {
context.fErrors->error(line, "array size must appear after variable name");
}
if (baseType->componentType().isOpaque() && storage != Variable::Storage::kGlobal) {
context.fErrors->error(line,
"variables of type '" + baseType->displayName() + "' must be global");

View File

@ -1,6 +1,4 @@
### Compilation failed:
error: 3: array size must appear after variable name
error: 5: array size must appear after variable name
error: 7: construction of array type 'float[3]' is not supported
3 errors
error: 5: construction of array type 'float[3]' is not supported
1 error