mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Changed the type of parameter in FunctionType ctor from generic Expression to TupleLiteral to match the grammar (#1272)
This commit is contained in:
@@ -19,7 +19,7 @@ message CallExpression {
|
||||
}
|
||||
|
||||
message FunctionTypeLiteral {
|
||||
optional Expression parameter = 1;
|
||||
optional TupleLiteralExpression parameter = 3;
|
||||
optional Expression return_type = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+11
-13
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -29,11 +29,9 @@ compilation_unit {
|
||||
expression {
|
||||
function_type {
|
||||
parameter {
|
||||
tuple_literal {
|
||||
fields {
|
||||
identifier {
|
||||
name: "T"
|
||||
}
|
||||
fields {
|
||||
identifier {
|
||||
name: "T"
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-9
@@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -22,11 +22,9 @@ compilation_unit {
|
||||
expression {
|
||||
function_type {
|
||||
parameter {
|
||||
tuple_literal {
|
||||
fields {
|
||||
identifier {
|
||||
name: "T"
|
||||
}
|
||||
fields {
|
||||
identifier {
|
||||
name: "T"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user