Changed the type of parameter in FunctionType ctor from generic Expression to TupleLiteral to match the grammar (#1272)

This commit is contained in:
pk19604014
2022-05-20 17:36:17 -07:00
committed by GitHub
parent 8dd398807d
commit cdc9428984
9 changed files with 31 additions and 40 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ message CallExpression {
}
message FunctionTypeLiteral {
optional Expression parameter = 1;
optional TupleLiteralExpression parameter = 3;
optional Expression return_type = 2;
}
+1 -1
View File
@@ -200,7 +200,7 @@ static auto ExpressionToCarbon(const Fuzzing::Expression& expression,
case Fuzzing::Expression::kFunctionType: {
const auto& fun_type = expression.function_type();
out << "__Fn";
ExpressionToCarbon(fun_type.parameter(), out);
TupleLiteralExpressionToCarbon(fun_type.parameter(), out);
out << " -> ";
ExpressionToCarbon(fun_type.return_type(), out);
break;
+4 -4
View File
@@ -489,7 +489,7 @@ class CallExpression : public Expression {
class FunctionTypeLiteral : public Expression {
public:
explicit FunctionTypeLiteral(SourceLocation source_loc,
Nonnull<Expression*> parameter,
Nonnull<TupleLiteral*> parameter,
Nonnull<Expression*> return_type)
: Expression(AstNodeKind::FunctionTypeLiteral, source_loc),
parameter_(parameter),
@@ -499,13 +499,13 @@ class FunctionTypeLiteral : public Expression {
return InheritsFromFunctionTypeLiteral(node->kind());
}
auto parameter() const -> const Expression& { return *parameter_; }
auto parameter() -> Expression& { return *parameter_; }
auto parameter() const -> const TupleLiteral& { return *parameter_; }
auto parameter() -> TupleLiteral& { return *parameter_; }
auto return_type() const -> const Expression& { return *return_type_; }
auto return_type() -> Expression& { return *return_type_; }
private:
Nonnull<Expression*> parameter_;
Nonnull<TupleLiteral*> parameter_;
Nonnull<Expression*> return_type_;
};
+1 -1
View File
@@ -97,7 +97,7 @@ static auto ExpressionToProto(const Expression& expression)
const auto& fun_type = cast<FunctionTypeLiteral>(expression);
auto* fun_type_proto = expression_proto.mutable_function_type();
*fun_type_proto->mutable_parameter() =
ExpressionToProto(fun_type.parameter());
TupleLiteralExpressionToProto(fun_type.parameter());
*fun_type_proto->mutable_return_type() =
ExpressionToProto(fun_type.return_type());
break;
@@ -245,20 +245,18 @@ compilation_unit {
type {
function_type {
parameter {
tuple_literal {
fields {
call {
function {
identifier {
name: "Point"
}
fields {
call {
function {
identifier {
name: "Point"
}
argument {
tuple_literal {
fields {
identifier {
name: "T"
}
}
argument {
tuple_literal {
fields {
identifier {
name: "T"
}
}
}
@@ -29,11 +29,9 @@ compilation_unit {
expression {
function_type {
parameter {
tuple_literal {
fields {
identifier {
name: "T"
}
fields {
identifier {
name: "T"
}
}
}
@@ -422,11 +422,9 @@ compilation_unit {
expression {
function_type {
parameter {
tuple_literal {
fields {
identifier {
name: "T"
}
fields {
identifier {
name: "T"
}
}
}
@@ -463,10 +461,8 @@ compilation_unit {
expression {
function_type {
parameter {
tuple_literal {
fields {
int_type_literal {
}
fields {
int_type_literal {
}
}
}
@@ -22,11 +22,9 @@ compilation_unit {
expression {
function_type {
parameter {
tuple_literal {
fields {
identifier {
name: "T"
}
fields {
identifier {
name: "T"
}
}
}
+2 -1
View File
@@ -29,7 +29,8 @@ TEST(FuzzerUtilTest, RunFuzzerOnCorpus) {
contents << file.rdbuf();
Fuzzing::Carbon carbon_proto;
ASSERT_TRUE(google::protobuf::TextFormat::ParseFromString(contents.str(),
&carbon_proto));
&carbon_proto))
<< " couldn't parse text proto in " << f;
ParseAndExecute(carbon_proto.compilation_unit());
++file_count;
}