diff --git a/src/Draco.Compiler.Tests/Semantics/AttributeTests.cs b/src/Draco.Compiler.Tests/Semantics/AttributeTests.cs index b2c8cfbd5..aee64a4fd 100644 --- a/src/Draco.Compiler.Tests/Semantics/AttributeTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/AttributeTests.cs @@ -103,7 +103,7 @@ public void AttributeIsWrittenIntoMetadata() FunctionDeclaration( [Attribute(NameType("ObsoleteAttribute"), StringExpression("do not use this function"))], "foo", - ParameterList(Parameter([Attribute(NameType("AllowNullAttribute"))], "arg", NameType("object"))), + ParameterList(NormalParameter([Attribute(NameType("AllowNullAttribute"))], "arg", NameType("object"))), null, BlockFunctionBody()))); @@ -132,7 +132,7 @@ public void AttributeReferencesTheSymbol() FunctionDeclaration( [Attribute(NameType("ObsoleteAttribute"), StringExpression("do not use this function"))], "foo", - ParameterList(Parameter([Attribute(NameType("AllowNullAttribute"))], "arg", NameType("object"))), + ParameterList(NormalParameter([Attribute(NameType("AllowNullAttribute"))], "arg", NameType("object"))), null, BlockFunctionBody()))); diff --git a/src/Draco.Compiler.Tests/Semantics/ControlFlowGraphTests.cs b/src/Draco.Compiler.Tests/Semantics/ControlFlowGraphTests.cs index dcdcdd0c5..c1fb579f7 100644 --- a/src/Draco.Compiler.Tests/Semantics/ControlFlowGraphTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/ControlFlowGraphTests.cs @@ -83,7 +83,7 @@ public async Task IfElse() var program = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "main", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( ExpressionStatement(IfExpression( @@ -149,7 +149,7 @@ public async Task EarlyReturn() var program = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "main", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( ExpressionStatement(CallExpression(NameExpression("bar"))), @@ -181,7 +181,7 @@ public async Task ConditionalGotoInAssignment() var program = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "main", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( DeclarationStatement(VariableDeclaration(true, "x", null, IfExpression( @@ -211,14 +211,14 @@ public async Task ForLoop() var program = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "main", - ParameterList(Parameter("s", GenericType(NameType("Array"), NameType("int32")))), + ParameterList(NormalParameter("s", GenericType(NameType("Array"), NameType("int32")))), null, BlockFunctionBody( ExpressionStatement(ForExpression( "i", NameExpression("s"), CallExpression(NameExpression("bar"), NameExpression("i")))))), - FunctionDeclaration("bar", ParameterList(Parameter("x", NameType("int32"))), null, BlockFunctionBody()))); + FunctionDeclaration("bar", ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody()))); // Act var cfg = FunctionToCfg(program); @@ -243,10 +243,10 @@ public async Task ChainedComparison() FunctionDeclaration( "foo", ParameterList( - Parameter("a", NameType("int32")), - Parameter("b", NameType("int32")), - Parameter("c", NameType("int32")), - Parameter("d", NameType("int32"))), + NormalParameter("a", NameType("int32")), + NormalParameter("b", NameType("int32")), + NormalParameter("c", NameType("int32")), + NormalParameter("d", NameType("int32"))), null, InlineFunctionBody(RelationalExpression( BlockExpression([ExpressionStatement(CallExpression(NameExpression("bar")))], NameExpression("a")), diff --git a/src/Draco.Compiler.Tests/Semantics/DefiniteAssignmentTests.cs b/src/Draco.Compiler.Tests/Semantics/DefiniteAssignmentTests.cs index 27999f55c..4192c5295 100644 --- a/src/Draco.Compiler.Tests/Semantics/DefiniteAssignmentTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/DefiniteAssignmentTests.cs @@ -69,7 +69,7 @@ public void UseOfConditionallyAssignedVariable() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))), @@ -100,7 +100,7 @@ public void UseOfConditionallyAssignedVariableOnBothBranches() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))), @@ -130,7 +130,7 @@ public void JumpingMidAssignment() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"), IfExpression( @@ -189,7 +189,7 @@ public void UseVariableAssignedLater() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( ExpressionStatement(WhileExpression( diff --git a/src/Draco.Compiler.Tests/Semantics/LocalFunctionsTests.cs b/src/Draco.Compiler.Tests/Semantics/LocalFunctionsTests.cs index 2339fb4f3..3958fe655 100644 --- a/src/Draco.Compiler.Tests/Semantics/LocalFunctionsTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/LocalFunctionsTests.cs @@ -24,13 +24,13 @@ public void ParameterRedefinitionError() BlockFunctionBody(DeclarationStatement(FunctionDeclaration( "bar", ParameterList( - Parameter("x", NameType("int32")), - Parameter("x", NameType("int32"))), + NormalParameter("x", NameType("int32")), + NormalParameter("x", NameType("int32"))), null, BlockFunctionBody())))))); - var x1Decl = tree.GetNode(0); - var x2Decl = tree.GetNode(1); + var x1Decl = tree.GetNode(0); + var x2Decl = tree.GetNode(1); // Act var compilation = CreateCompilation(tree); @@ -190,7 +190,7 @@ public void LocalFunctionContributesToOverloading() var tree = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( name: "foo", - parameters: ParameterList(Parameter("x", NameType("int32"))), + parameters: ParameterList(NormalParameter("x", NameType("int32"))), returnType: null, body: BlockFunctionBody()), FunctionDeclaration( @@ -200,7 +200,7 @@ public void LocalFunctionContributesToOverloading() body: BlockFunctionBody( DeclarationStatement(FunctionDeclaration( name: "foo", - parameters: ParameterList(Parameter("x", NameType("string"))), + parameters: ParameterList(NormalParameter("x", NameType("string"))), returnType: null, body: BlockFunctionBody())), ExpressionStatement(CallExpression(NameExpression("foo"), LiteralExpression(0))), diff --git a/src/Draco.Compiler.Tests/Semantics/OverloadingTests.cs b/src/Draco.Compiler.Tests/Semantics/OverloadingTests.cs index f8b21befe..7987b5067 100644 --- a/src/Draco.Compiler.Tests/Semantics/OverloadingTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/OverloadingTests.cs @@ -18,34 +18,34 @@ public sealed class OverloadingTests private static IEnumerable GetGenericListOverloads() => [ FunctionDeclaration( "foo", - ParameterList(Parameter("l", GenericType(NameType("List"), NameType("int32")))), + ParameterList(NormalParameter("l", GenericType(NameType("List"), NameType("int32")))), null, BlockFunctionBody()), FunctionDeclaration( "foo", - ParameterList(Parameter("l", GenericType(NameType("List"), NameType("string")))), + ParameterList(NormalParameter("l", GenericType(NameType("List"), NameType("string")))), null, BlockFunctionBody()), FunctionDeclaration( "foo", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("l", GenericType(NameType("List"), NameType("T")))), + ParameterList(NormalParameter("l", GenericType(NameType("List"), NameType("T")))), null, BlockFunctionBody()), FunctionDeclaration( "foo", - ParameterList(Parameter("l", GenericType(NameType("IEnumerable"), NameType("int32")))), + ParameterList(NormalParameter("l", GenericType(NameType("IEnumerable"), NameType("int32")))), null, BlockFunctionBody()), FunctionDeclaration( "foo", - ParameterList(Parameter("l", GenericType(NameType("IEnumerable"), NameType("string")))), + ParameterList(NormalParameter("l", GenericType(NameType("IEnumerable"), NameType("string")))), null, BlockFunctionBody()), FunctionDeclaration( "foo", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("l", GenericType(NameType("IEnumerable"), NameType("T")))), + ParameterList(NormalParameter("l", GenericType(NameType("IEnumerable"), NameType("T")))), null, BlockFunctionBody()), ]; diff --git a/src/Draco.Compiler.Tests/Semantics/ReturnsOnAllPathsTests.cs b/src/Draco.Compiler.Tests/Semantics/ReturnsOnAllPathsTests.cs index 0c65af6c7..efc977dcd 100644 --- a/src/Draco.Compiler.Tests/Semantics/ReturnsOnAllPathsTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/ReturnsOnAllPathsTests.cs @@ -98,7 +98,7 @@ public void NonUnitMethodReturnsConditionally() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), NameType("int32"), BlockFunctionBody( ExpressionStatement(IfExpression( @@ -124,7 +124,7 @@ public void NonUnitMethodReturnsConditionallyOnBothBranches() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), NameType("int32"), BlockFunctionBody( ExpressionStatement(IfExpression( @@ -151,7 +151,7 @@ public void NonUnitMethodReturnsConditionallyButThenUnconditionally() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), NameType("int32"), BlockFunctionBody( ExpressionStatement(IfExpression( @@ -177,7 +177,7 @@ public void NonUnitMethodReturnsInConditionalLoop() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), NameType("int32"), BlockFunctionBody( ExpressionStatement(WhileExpression( diff --git a/src/Draco.Compiler.Tests/Semantics/SingleAssignmentTests.cs b/src/Draco.Compiler.Tests/Semantics/SingleAssignmentTests.cs index d3669c9e9..c4064fea9 100644 --- a/src/Draco.Compiler.Tests/Semantics/SingleAssignmentTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/SingleAssignmentTests.cs @@ -66,7 +66,7 @@ public void AssignImmutableInMutuallyExclusiveBranches() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( DeclarationStatement(ImmutableVariableDeclaration(true, "x", NameType("int32"))), @@ -95,7 +95,7 @@ public void ConditionallyAndThenUnconditionallyAssignImmutable() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( DeclarationStatement(ImmutableVariableDeclaration(true, "x", NameType("int32"))), @@ -124,7 +124,7 @@ public void AssignImmutableInLoop() // } var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("b", NameType("bool"))), + ParameterList(NormalParameter("b", NameType("bool"))), null, BlockFunctionBody( DeclarationStatement(ImmutableVariableDeclaration(true, "x", NameType("int32"))), diff --git a/src/Draco.Compiler.Tests/Semantics/SymbolResolutionTests.cs b/src/Draco.Compiler.Tests/Semantics/SymbolResolutionTests.cs index f9479a94b..9711e1959 100644 --- a/src/Draco.Compiler.Tests/Semantics/SymbolResolutionTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/SymbolResolutionTests.cs @@ -40,7 +40,7 @@ public void BasicScopeTree() var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", ParameterList( - Parameter("n", NameType("int32"))), + NormalParameter("n", NameType("int32"))), null, BlockFunctionBody( DeclarationStatement(VariableDeclaration(true, "x1")), @@ -53,7 +53,7 @@ public void BasicScopeTree() ExpressionStatement(BlockExpression(DeclarationStatement(VariableDeclaration(true, "x6")))))))))); var foo = tree.GetNode(); - var n = tree.GetNode(); + var n = tree.GetNode(); var x1 = tree.GetNode(0); var x2 = tree.GetNode(1); var x3 = tree.GetNode(2); @@ -327,13 +327,13 @@ public void ParameterRedefinitionError() var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", ParameterList( - Parameter("x", NameType("int32")), - Parameter("x", NameType("int32"))), + NormalParameter("x", NameType("int32")), + NormalParameter("x", NameType("int32"))), null, BlockFunctionBody()))); - var x1Decl = tree.GetNode(0); - var x2Decl = tree.GetNode(1); + var x1Decl = tree.GetNode(0); + var x2Decl = tree.GetNode(1); // Act var compilation = CreateCompilation(tree); @@ -361,14 +361,14 @@ public void RedefinedParameterReference() var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", ParameterList( - Parameter("x", NameType("int32")), - Parameter("x", NameType("int32"))), + NormalParameter("x", NameType("int32")), + NormalParameter("x", NameType("int32"))), null, BlockFunctionBody( DeclarationStatement(VariableDeclaration(true, "y", null, NameExpression("x"))))))); - var x1Decl = tree.GetNode(0); - var x2Decl = tree.GetNode(1); + var x1Decl = tree.GetNode(0); + var x2Decl = tree.GetNode(1); var xRef = tree.GetNode(0); // Act @@ -418,7 +418,7 @@ public void FuncOverloadsGlobalVar() VariableDeclaration(true, "b", NameType("int32")), FunctionDeclaration( "b", - ParameterList(Parameter("b", NameType("int32"))), + ParameterList(NormalParameter("b", NameType("int32"))), NameType("int32"), InlineFunctionBody(NameExpression("b"))))); @@ -1664,7 +1664,7 @@ public void UndefinedTypeInParameterType() // Arrange var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("unknown"))), + ParameterList(NormalParameter("x", NameType("unknown"))), null, BlockFunctionBody()))); @@ -3246,7 +3246,7 @@ public void GenericFunction() var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("T"))), + ParameterList(NormalParameter("x", NameType("T"))), NameType("T"), InlineFunctionBody(NameExpression("x"))))); diff --git a/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs b/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs index 6583a3585..761246072 100644 --- a/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs @@ -655,7 +655,7 @@ public void OneVisibleAndOneNotVisibleOverloadImported() FunctionDeclaration( Api.Semantics.Visibility.Internal, "foo", - ParameterList(Parameter("x", NameType("string"))), + ParameterList(NormalParameter("x", NameType("string"))), NameType("int32"), InlineFunctionBody(LiteralExpression(0)))), ToPath("Tests", "FooModule", "foo.draco")); @@ -702,7 +702,7 @@ public void OneVisibleAndOneNotVisibleOverloadFullyQualified() FunctionDeclaration( Api.Semantics.Visibility.Internal, "foo", - ParameterList(Parameter("x", NameType("string"))), + ParameterList(NormalParameter("x", NameType("string"))), NameType("int32"), InlineFunctionBody(LiteralExpression(0)))), ToPath("Tests", "FooModule", "foo.draco")); @@ -736,12 +736,12 @@ public void OkOverloading() var tree = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody()), FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("bool"))), + ParameterList(NormalParameter("x", NameType("bool"))), null, BlockFunctionBody()), FunctionDeclaration( @@ -788,12 +788,12 @@ public void OkNestedOverloading() var tree = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody( DeclarationStatement(FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("bool"))), + ParameterList(NormalParameter("x", NameType("bool"))), null, BlockFunctionBody())), ExpressionStatement(CallExpression(NameExpression("foo"), LiteralExpression(0))), @@ -837,12 +837,12 @@ public void NestedOverloadNotVisibleFromOutside() var tree = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody( DeclarationStatement(FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("bool"))), + ParameterList(NormalParameter("x", NameType("bool"))), null, BlockFunctionBody())))), FunctionDeclaration( @@ -888,12 +888,12 @@ public void IllegalOverloading() var tree = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody()), FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody()))); @@ -919,13 +919,13 @@ public void IllegalOverloadingWithGenerics() FunctionDeclaration( "foo", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("int32")), Parameter("y", NameType("T"))), + ParameterList(NormalParameter("x", NameType("int32")), NormalParameter("y", NameType("T"))), null, BlockFunctionBody()), FunctionDeclaration( "foo", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("int32")), Parameter("y", NameType("T"))), + ParameterList(NormalParameter("x", NameType("int32")), NormalParameter("y", NameType("T"))), null, BlockFunctionBody()))); @@ -951,12 +951,12 @@ public void IllegalNestedOverloading() var tree = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody( DeclarationStatement(FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody())))))); @@ -992,12 +992,12 @@ public void NestedMatchingLocalOverloads() var tree = SyntaxTree.Create(CompilationUnit( FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), null, BlockFunctionBody( DeclarationStatement(FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("bool"))), + ParameterList(NormalParameter("x", NameType("bool"))), null, BlockFunctionBody( ExpressionStatement(CallExpression(NameExpression("foo"), LiteralExpression(0))), @@ -1009,7 +1009,7 @@ public void NestedMatchingLocalOverloads() BlockFunctionBody( DeclarationStatement(FunctionDeclaration( "foo", - ParameterList(Parameter("x", NameType("bool"))), + ParameterList(NormalParameter("x", NameType("bool"))), null, BlockFunctionBody( ExpressionStatement(CallExpression(NameExpression("foo"), LiteralExpression(0))), @@ -1191,7 +1191,7 @@ public void ExplicitGenericFunction() FunctionDeclaration( "identity", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("T"))), + ParameterList(NormalParameter("x", NameType("T"))), NameType("T"), InlineFunctionBody(NameExpression("x"))), FunctionDeclaration( @@ -1269,7 +1269,7 @@ public void ExplicitGenericFunctionWithWrongNumberOfArgs() FunctionDeclaration( "identity", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("T"))), + ParameterList(NormalParameter("x", NameType("T"))), NameType("T"), InlineFunctionBody(NameExpression("x"))), FunctionDeclaration( @@ -1362,7 +1362,7 @@ public void InferGenericFunctionParameterTypeFromUse() FunctionDeclaration( "identity", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("T"))), + ParameterList(NormalParameter("x", NameType("T"))), NameType("T"), InlineFunctionBody(NameExpression("x"))), FunctionDeclaration( @@ -1490,12 +1490,12 @@ public void ExactMatchOverloadPriorityOverGeneric() FunctionDeclaration( "identity", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("T"))), + ParameterList(NormalParameter("x", NameType("T"))), NameType("T"), InlineFunctionBody(NameExpression("x"))), FunctionDeclaration( "identity", - ParameterList(Parameter("x", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("int32"))), NameType("int32"), InlineFunctionBody(NameExpression("x"))), FunctionDeclaration( @@ -1551,13 +1551,13 @@ public void AmbiguousOverload() FunctionDeclaration( "foo", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("T")), Parameter("y", NameType("int32"))), + ParameterList(NormalParameter("x", NameType("T")), NormalParameter("y", NameType("int32"))), null, BlockFunctionBody()), FunctionDeclaration( "foo", GenericParameterList(GenericParameter("T")), - ParameterList(Parameter("x", NameType("int32")), Parameter("y", NameType("T"))), + ParameterList(NormalParameter("x", NameType("int32")), NormalParameter("y", NameType("T"))), null, BlockFunctionBody()), FunctionDeclaration( @@ -1595,14 +1595,14 @@ public void VariadicOverloadPriority() FunctionDeclaration( "bar", ParameterList( - Parameter("s", NameType("string")), - Parameter("x", NameType("int32"))), + NormalParameter("s", NameType("string")), + NormalParameter("x", NameType("int32"))), NameType("int32"), InlineFunctionBody(LiteralExpression(0))), FunctionDeclaration( "bar", ParameterList( - Parameter("s", NameType("string")), + NormalParameter("s", NameType("string")), VariadicParameter("x", GenericType(NameType("Array"), NameType("int32")))), NameType("int32"), InlineFunctionBody(LiteralExpression(0))), @@ -1666,15 +1666,15 @@ public void GenericVariadicOverloadPriority() "bar", GenericParameterList(GenericParameter("T")), ParameterList( - Parameter("s", NameType("string")), - Parameter("x", NameType("T"))), + NormalParameter("s", NameType("string")), + NormalParameter("x", NameType("T"))), NameType("int32"), InlineFunctionBody(LiteralExpression(0))), FunctionDeclaration( "bar", GenericParameterList(GenericParameter("T")), ParameterList( - Parameter("s", NameType("string")), + NormalParameter("s", NameType("string")), VariadicParameter("x", GenericType(NameType("Array"), NameType("T")))), NameType("int32"), InlineFunctionBody(LiteralExpression(0))), @@ -1732,8 +1732,8 @@ public void InferredGenericsMismatch() "foo", GenericParameterList(GenericParameter("T")), ParameterList( - Parameter("x", NameType("T")), - Parameter("y", NameType("T"))), + NormalParameter("x", NameType("T")), + NormalParameter("y", NameType("T"))), null, BlockFunctionBody()), FunctionDeclaration( @@ -1886,7 +1886,7 @@ public void PassDerivedTypeToBaseTypeParameter() ExpressionStatement(CallExpression(NameExpression("bar"), CallExpression(NameExpression("Random")))))), FunctionDeclaration( "bar", - ParameterList(Parameter("x", NameType("Object"))), + ParameterList(NormalParameter("x", NameType("Object"))), null, BlockFunctionBody()))); @@ -1922,7 +1922,7 @@ public void PassBaseTypeToDerivedTypeParameter() ExpressionStatement(CallExpression(NameExpression("bar"), CallExpression(NameExpression("Object")))))), FunctionDeclaration( "bar", - ParameterList(Parameter("x", NameType("String"))), + ParameterList(NormalParameter("x", NameType("String"))), null, BlockFunctionBody()))); @@ -1961,12 +1961,12 @@ public void BaseTypeArgumentOverloading() ExpressionStatement(CallExpression(NameExpression("bar"), CallExpression(NameExpression("Object")))))), FunctionDeclaration( "bar", - ParameterList(Parameter("x", NameType("Object"))), + ParameterList(NormalParameter("x", NameType("Object"))), null, BlockFunctionBody()), FunctionDeclaration( "bar", - ParameterList(Parameter("x", NameType("Random"))), + ParameterList(NormalParameter("x", NameType("Random"))), null, BlockFunctionBody()))); @@ -2019,9 +2019,9 @@ public void BaseTypeGenericsCall() "bar", GenericParameterList(GenericParameter("T")), ParameterList( - Parameter("x", NameType("T")), - Parameter("y", NameType("T")), - Parameter("z", NameType("T"))), + NormalParameter("x", NameType("T")), + NormalParameter("y", NameType("T")), + NormalParameter("z", NameType("T"))), null, BlockFunctionBody()))); @@ -2417,7 +2417,7 @@ public void GenericTypeNotInstantiatedInTypeContextIsAnError() var main = SyntaxTree.Create(CompilationUnit(FunctionDeclaration( "foo", - ParameterList(Parameter("a", NameType("Array2D"))), + ParameterList(NormalParameter("a", NameType("Array2D"))), null, BlockFunctionBody()))); diff --git a/src/Draco.Compiler.Tests/Syntax/ParserTests.cs b/src/Draco.Compiler.Tests/Syntax/ParserTests.cs index 08f6e8ea5..f44cac6fc 100644 --- a/src/Draco.Compiler.Tests/Syntax/ParserTests.cs +++ b/src/Draco.Compiler.Tests/Syntax/ParserTests.cs @@ -100,7 +100,7 @@ func main() { this.T(TokenKind.Identifier); this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); this.T(TokenKind.ParenClose); this.N(); @@ -170,7 +170,7 @@ func main() { this.T(TokenKind.Identifier); this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); this.T(TokenKind.ParenClose); this.N(); @@ -199,7 +199,7 @@ func main() { this.T(TokenKind.Identifier); this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); this.T(TokenKind.ParenClose); this.N(); @@ -247,7 +247,7 @@ func foo() { } this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); this.T(TokenKind.ParenClose); this.N(); @@ -1988,9 +1988,9 @@ func foo(@Attr2("this is a parameter") x: int32) {} this.T(TokenKind.KeywordFunc); this.T(TokenKind.Identifier, "foo"); this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); { - this.N(); + this.N(); { this.N>(); this.N(); @@ -2051,7 +2051,7 @@ public func bar() {} this.T(TokenKind.KeywordFunc); this.T(TokenKind.Identifier, "foo"); this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); this.T(TokenKind.ParenClose); this.N(); { @@ -2064,7 +2064,7 @@ public func bar() {} this.T(TokenKind.KeywordFunc); this.T(TokenKind.Identifier, "bar"); this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); this.T(TokenKind.ParenClose); this.N(); { @@ -2096,7 +2096,7 @@ public void TestEmptyGenericParameterList() this.T(TokenKind.GreaterThan); } this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); this.T(TokenKind.ParenClose); this.N(); { @@ -2119,9 +2119,9 @@ func foo(x: List<>) {} this.T(TokenKind.KeywordFunc); this.T(TokenKind.Identifier, "foo"); this.T(TokenKind.ParenOpen); - this.N>(); + this.N>(); { - this.N(); + this.N(); { this.T(TokenKind.Identifier, "x"); this.T(TokenKind.Colon); diff --git a/src/Draco.Compiler/Api/Services/CodeCompletion/CompletionService.cs b/src/Draco.Compiler/Api/Services/CodeCompletion/CompletionService.cs index 318d3c1f2..38b9c3ed1 100644 --- a/src/Draco.Compiler/Api/Services/CodeCompletion/CompletionService.cs +++ b/src/Draco.Compiler/Api/Services/CodeCompletion/CompletionService.cs @@ -87,7 +87,7 @@ public ImmutableArray GetCompletions(SemanticModel semanticModel // Type expression NameTypeSyntax => CompletionContext.Type, // Parameter name declaration - ParameterSyntax => CompletionContext.None, + NormalParameterSyntax => CompletionContext.None, // Global declaration UnexpectedDeclarationSyntax => CompletionContext.Declaration, // Declaring identifier diff --git a/src/Draco.Compiler/Api/Syntax/SyntaxFactory.cs b/src/Draco.Compiler/Api/Syntax/SyntaxFactory.cs index a0a11b340..321b3935c 100644 --- a/src/Draco.Compiler/Api/Syntax/SyntaxFactory.cs +++ b/src/Draco.Compiler/Api/Syntax/SyntaxFactory.cs @@ -93,16 +93,16 @@ public static SeparatedSyntaxList SeparatedSyntaxList(SyntaxToken public static SeparatedSyntaxList SeparatedSyntaxList(SyntaxToken separator, params TNode[] elements) where TNode : SyntaxNode => SeparatedSyntaxList(separator, elements.AsEnumerable()); - public static SeparatedSyntaxList ParameterList(IEnumerable parameters) => + public static SeparatedSyntaxList ParameterList(IEnumerable parameters) => SeparatedSyntaxList(Comma, parameters); - public static SeparatedSyntaxList ParameterList(params ParameterSyntaxBase[] parameters) => + public static SeparatedSyntaxList ParameterList(params ParameterSyntax[] parameters) => SeparatedSyntaxList(Comma, parameters); - public static ParameterSyntax Parameter(string name, TypeSyntax type) => - Parameter([], name, type); - public static ParameterSyntax Parameter(IEnumerable attributes, string name, TypeSyntax type) => - Parameter(SyntaxList(attributes), null, Identifier(name), Colon, type); - public static ParameterSyntax VariadicParameter(string name, TypeSyntax type) => - Parameter(SyntaxList(), Ellipsis, Identifier(name), Colon, type); + public static NormalParameterSyntax NormalParameter(string name, TypeSyntax type) => + NormalParameter([], name, type); + public static NormalParameterSyntax NormalParameter(IEnumerable attributes, string name, TypeSyntax type) => + NormalParameter(SyntaxList(attributes), null, Identifier(name), Colon, type); + public static NormalParameterSyntax VariadicParameter(string name, TypeSyntax type) => + NormalParameter(SyntaxList(), Ellipsis, Identifier(name), Colon, type); public static GenericParameterListSyntax GenericParameterList(IEnumerable parameters) => GenericParameterList(SeparatedSyntaxList(Comma, parameters)); @@ -123,7 +123,7 @@ public static ImportDeclarationSyntax ImportDeclaration(string root, params stri public static FunctionDeclarationSyntax FunctionDeclaration( string name, - SeparatedSyntaxList parameters, + SeparatedSyntaxList parameters, TypeSyntax? returnType, FunctionBodySyntax body) => FunctionDeclaration([], Semantics.Visibility.Private, name, null, parameters, returnType, body); @@ -131,7 +131,7 @@ public static FunctionDeclarationSyntax FunctionDeclaration( public static FunctionDeclarationSyntax FunctionDeclaration( IEnumerable attributes, string name, - SeparatedSyntaxList parameters, + SeparatedSyntaxList parameters, TypeSyntax? returnType, FunctionBodySyntax body) => FunctionDeclaration(attributes, Semantics.Visibility.Private, name, null, parameters, returnType, body); @@ -139,7 +139,7 @@ public static FunctionDeclarationSyntax FunctionDeclaration( public static FunctionDeclarationSyntax FunctionDeclaration( Visibility visibility, string name, - SeparatedSyntaxList parameters, + SeparatedSyntaxList parameters, TypeSyntax? returnType, FunctionBodySyntax body) => FunctionDeclaration([], visibility, name, null, parameters, returnType, body); @@ -147,7 +147,7 @@ public static FunctionDeclarationSyntax FunctionDeclaration( public static FunctionDeclarationSyntax FunctionDeclaration( string name, GenericParameterListSyntax? generics, - SeparatedSyntaxList parameters, + SeparatedSyntaxList parameters, TypeSyntax? returnType, FunctionBodySyntax body) => FunctionDeclaration([], Semantics.Visibility.Private, name, generics, parameters, returnType, body); @@ -157,7 +157,7 @@ public static FunctionDeclarationSyntax FunctionDeclaration( Visibility visibility, string name, GenericParameterListSyntax? generics, - SeparatedSyntaxList parameters, + SeparatedSyntaxList parameters, TypeSyntax? returnType, FunctionBodySyntax body) => FunctionDeclaration( attributes, diff --git a/src/Draco.Compiler/Api/Syntax/SyntaxFacts.cs b/src/Draco.Compiler/Api/Syntax/SyntaxFacts.cs index 078baffe7..3661d6972 100644 --- a/src/Draco.Compiler/Api/Syntax/SyntaxFacts.cs +++ b/src/Draco.Compiler/Api/Syntax/SyntaxFacts.cs @@ -157,7 +157,7 @@ _ when IsMissing(node) => false, ModuleDeclarationSyntax md => !IsMissing(md.CloseBrace), ImportDeclarationSyntax id => !IsMissing(id.Semicolon), FunctionDeclarationSyntax fd => IsCompleteEntry(fd.Body), - ParameterSyntax p => IsCompleteEntry(p.Type), + NormalParameterSyntax p => IsCompleteEntry(p.Type), BlockFunctionBodySyntax bfb => !IsMissing(bfb.CloseBrace), InlineFunctionBodySyntax ifb => !IsMissing(ifb.Semicolon), LabelDeclarationSyntax ld => !IsMissing(ld.Colon), diff --git a/src/Draco.Compiler/Api/Syntax/SyntaxHighlighter.cs b/src/Draco.Compiler/Api/Syntax/SyntaxHighlighter.cs index 6e50d7956..2e49eea72 100644 --- a/src/Draco.Compiler/Api/Syntax/SyntaxHighlighter.cs +++ b/src/Draco.Compiler/Api/Syntax/SyntaxHighlighter.cs @@ -140,7 +140,7 @@ or TokenKind.BracketOpen private static IEnumerable Identifier(SyntaxToken token, SemanticModel? semanticModel) { // Make a guess based on syntax - if (token.Parent is ParameterSyntax param && param.Name.Equals(token)) + if (token.Parent is NormalParameterSyntax param && param.Name.Equals(token)) { return Fragment(token, SyntaxColoring.ParameterName); } diff --git a/src/Draco.Compiler/Internal/Binding/BinderFacts.cs b/src/Draco.Compiler/Internal/Binding/BinderFacts.cs index 0108c1ace..c8f9d9ba9 100644 --- a/src/Draco.Compiler/Internal/Binding/BinderFacts.cs +++ b/src/Draco.Compiler/Internal/Binding/BinderFacts.cs @@ -133,7 +133,7 @@ or ForExpressionSyntax public static bool DefinesSymbol(SyntaxNode node) => node is FunctionDeclarationSyntax or VariableDeclarationSyntax - or ParameterSyntax + or NormalParameterSyntax or LabelDeclarationSyntax or ClassDeclarationSyntax; diff --git a/src/Draco.Compiler/Internal/Binding/Binder_Expression.cs b/src/Draco.Compiler/Internal/Binding/Binder_Expression.cs index c8677c549..52e414482 100644 --- a/src/Draco.Compiler/Internal/Binding/Binder_Expression.cs +++ b/src/Draco.Compiler/Internal/Binding/Binder_Expression.cs @@ -13,15 +13,7 @@ using Draco.Compiler.Internal.Symbols; using Draco.Compiler.Internal.Symbols.Error; using Draco.Compiler.Internal.Symbols.Syntax; -using FieldSymbol = Draco.Compiler.Internal.Symbols.FieldSymbol; -using FunctionGroupSymbol = Draco.Compiler.Internal.Symbols.Synthetized.FunctionGroupSymbol; -using FunctionSymbol = Draco.Compiler.Internal.Symbols.FunctionSymbol; -using LabelSymbol = Draco.Compiler.Internal.Symbols.LabelSymbol; -using LocalSymbol = Draco.Compiler.Internal.Symbols.LocalSymbol; -using ModuleSymbol = Draco.Compiler.Internal.Symbols.ModuleSymbol; -using ParameterSymbol = Draco.Compiler.Internal.Symbols.ParameterSymbol; -using PropertySymbol = Draco.Compiler.Internal.Symbols.PropertySymbol; -using TypeSymbol = Draco.Compiler.Internal.Symbols.TypeSymbol; +using Draco.Compiler.Internal.Symbols.Synthetized; namespace Draco.Compiler.Internal.Binding; @@ -74,7 +66,7 @@ private async BindingTask BindExpressionToValueProducingExpress UnaryExpressionSyntax ury => this.BindUnaryExpression(ury, constraints, diagnostics), BinaryExpressionSyntax bin => this.BindBinaryExpression(bin, constraints, diagnostics), RelationalExpressionSyntax rel => this.BindRelationalExpression(rel, constraints, diagnostics), - MemberExpressionSyntax maccess => this.BindMemberExpression(maccess, constraints, diagnostics), + MemberExpressionSyntax mem => this.BindMemberExpression(mem, constraints, diagnostics), GenericExpressionSyntax gen => this.BindGenericExpression(gen, constraints, diagnostics), IndexExpressionSyntax index => this.BindIndexExpression(index, constraints, diagnostics), ThisExpressionSyntax @this => this.BindThisExpression(@this, constraints, diagnostics), @@ -718,10 +710,7 @@ private async BindingTask BindIndexExpression(IndexExpressionSy // Array getter return new BoundArrayAccessExpression(syntax, receiver, await BindingTask.WhenAll(argsTask)); } - else - { - return new BoundIndexGetExpression(syntax, receiver, indexer, await BindingTask.WhenAll(argsTask)); - } + return new BoundIndexGetExpression(syntax, receiver, indexer, await BindingTask.WhenAll(argsTask)); } private BindingTask BindThisExpression(ThisExpressionSyntax syntax, ConstraintSolver constraints, DiagnosticBag diagnostics) @@ -871,16 +860,13 @@ private BindingTask WrapFunctions( return BindingTask.FromResult( new BoundDelegateCreationExpression(syntax, receiver, functions[0], delegateCtor)); } - else - { - // TODO: We should construct some constraints to resolve which one - // For now we report an error to not crash tools - diagnostics.Add(Diagnostic.Create( - template: TypeCheckingErrors.IllegalExpression, - location: syntax.Location)); - return BindingTask.FromResult( - new BoundReferenceErrorExpression(syntax, WellKnownTypes.ErrorType)); - } + // TODO: We should construct some constraints to resolve which one + // For now we report an error to not crash tools + diagnostics.Add(Diagnostic.Create( + template: TypeCheckingErrors.IllegalExpression, + location: syntax.Location)); + return BindingTask.FromResult( + new BoundReferenceErrorExpression(syntax, WellKnownTypes.ErrorType)); } } diff --git a/src/Draco.Compiler/Internal/Binding/LocalBinder.cs b/src/Draco.Compiler/Internal/Binding/LocalBinder.cs index 57c99d461..ef569501b 100644 --- a/src/Draco.Compiler/Internal/Binding/LocalBinder.cs +++ b/src/Draco.Compiler/Internal/Binding/LocalBinder.cs @@ -168,7 +168,7 @@ private void Build() private Symbol? BuildSymbol(SyntaxNode syntax, int localCount) => syntax switch { FunctionDeclarationSyntax function => new SourceFunctionSymbol(this.ContainingSymbol, function), - ParameterSyntax parameter => new SourceParameterSymbol((FunctionSymbol)this.ContainingSymbol, parameter), + NormalParameterSyntax parameter => new SourceParameterSymbol((FunctionSymbol)this.ContainingSymbol, parameter), VariableDeclarationSyntax variable => variable.FieldKeyword is null ? new SourceLocalSymbol(this.ContainingSymbol, new TypeVariable(localCount), variable) : new SourceFieldSymbol((TypeSymbol)this.ContainingSymbol, variable), diff --git a/src/Draco.Compiler/Internal/Declarations/ClassDeclaration.cs b/src/Draco.Compiler/Internal/Declarations/ClassDeclaration.cs index a1e43c269..93f099509 100644 --- a/src/Draco.Compiler/Internal/Declarations/ClassDeclaration.cs +++ b/src/Draco.Compiler/Internal/Declarations/ClassDeclaration.cs @@ -21,13 +21,7 @@ internal sealed class ClassDeclaration(ClassDeclarationSyntax syntax) : Declarat InterlockedUtils.InitializeDefault(ref this.children, this.BuildChildren); private ImmutableArray children; - public override IEnumerable DeclaringSyntaxes - { - get - { - yield return this.Syntax; - } - } + public override IEnumerable DeclaringSyntaxes => [this.Syntax]; private ImmutableArray BuildChildren() { diff --git a/src/Draco.Compiler/Internal/Declarations/FunctionDeclaration.cs b/src/Draco.Compiler/Internal/Declarations/FunctionDeclaration.cs index 6ffc27b45..d1904330f 100644 --- a/src/Draco.Compiler/Internal/Declarations/FunctionDeclaration.cs +++ b/src/Draco.Compiler/Internal/Declarations/FunctionDeclaration.cs @@ -17,11 +17,5 @@ internal sealed class FunctionDeclaration(FunctionDeclarationSyntax syntax) public override ImmutableArray Children => []; - public override IEnumerable DeclaringSyntaxes - { - get - { - yield return this.Syntax; - } - } + public override IEnumerable DeclaringSyntaxes => [this.Syntax]; } diff --git a/src/Draco.Compiler/Internal/Declarations/GlobalDeclaration.cs b/src/Draco.Compiler/Internal/Declarations/GlobalDeclaration.cs index 9fcfe7dfb..fef7bfdba 100644 --- a/src/Draco.Compiler/Internal/Declarations/GlobalDeclaration.cs +++ b/src/Draco.Compiler/Internal/Declarations/GlobalDeclaration.cs @@ -17,11 +17,5 @@ internal sealed class GlobalDeclaration(VariableDeclarationSyntax syntax) public override ImmutableArray Children => []; - public override IEnumerable DeclaringSyntaxes - { - get - { - yield return this.Syntax; - } - } + public override IEnumerable DeclaringSyntaxes => [this.Syntax]; } diff --git a/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs b/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs index b3419e647..c2420a858 100644 --- a/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs +++ b/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs @@ -27,13 +27,7 @@ internal sealed class SingleModuleDeclaration(string name, SplitPath path, Conta InterlockedUtils.InitializeDefault(ref this.children, this.BuildChildren); private ImmutableArray children; - public override IEnumerable DeclaringSyntaxes - { - get - { - yield return this.Syntax; - } - } + public override IEnumerable DeclaringSyntaxes => [this.Syntax]; private ImmutableArray BuildChildren() => this.Syntax.Declarations.Select(this.BuildChild).OfType().ToImmutableArray(); diff --git a/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs index ca507aa63..f56897587 100644 --- a/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs @@ -12,7 +12,7 @@ namespace Draco.Compiler.Internal.Symbols.Source; /// internal sealed class SourceParameterSymbol( FunctionSymbol containingSymbol, - ParameterSyntax syntax) : ParameterSymbol, ISourceSymbol + NormalParameterSyntax syntax) : ParameterSymbol, ISourceSymbol { public override ImmutableArray Attributes => this.BindAttributesIfNeeded(this.DeclaringCompilation!); private ImmutableArray attributes; @@ -24,7 +24,7 @@ internal sealed class SourceParameterSymbol( public override bool IsVariadic => this.DeclaringSyntax.Variadic is not null; public override string Name => this.DeclaringSyntax.Name.Text; - public override ParameterSyntax DeclaringSyntax { get; } = syntax; + public override NormalParameterSyntax DeclaringSyntax { get; } = syntax; public void Bind(IBinderProvider binderProvider) { diff --git a/src/Draco.Compiler/Internal/Symbols/Syntax/SyntaxFunctionSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Syntax/SyntaxFunctionSymbol.cs index 77f3e9a2a..2ba7d9626 100644 --- a/src/Draco.Compiler/Internal/Symbols/Syntax/SyntaxFunctionSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Syntax/SyntaxFunctionSymbol.cs @@ -130,7 +130,7 @@ private ImmutableArray BindParameters(IBinderProvider binderPro parameters.Add(asSymbol); continue; } - var parameterSyntax = (ParameterSyntax)syntax; + var parameterSyntax = (NormalParameterSyntax)syntax; var parameterName = parameterSyntax.Name.Text; diff --git a/src/Draco.Compiler/Internal/Syntax/Parser.cs b/src/Draco.Compiler/Internal/Syntax/Parser.cs index 542f1c5ec..e58a88900 100644 --- a/src/Draco.Compiler/Internal/Syntax/Parser.cs +++ b/src/Draco.Compiler/Internal/Syntax/Parser.cs @@ -808,8 +808,8 @@ private DeclarationSyntax ParseLabelDeclaration( /// /// Parses a function parameter. /// - /// The parsed . - private ParameterSyntaxBase ParseParameter() + /// The parsed . + private ParameterSyntax ParseParameter() { var attributes = this.ParseAttributeList(); if (this.Matches(TokenKind.KeywordThis, out var thisKeyWord)) @@ -825,7 +825,7 @@ private ParameterSyntaxBase ParseParameter() var name = this.Expect(TokenKind.Identifier); var colon = this.Expect(TokenKind.Colon); var type = this.ParseType(); - return new ParameterSyntax(attributes, variadic, name, colon, type); + return new NormalParameterSyntax(attributes, variadic, name, colon, type); } /// diff --git a/src/Draco.Compiler/Internal/Syntax/Syntax.xml b/src/Draco.Compiler/Internal/Syntax/Syntax.xml index df71aa130..bf5a7dade 100644 --- a/src/Draco.Compiler/Internal/Syntax/Syntax.xml +++ b/src/Draco.Compiler/Internal/Syntax/Syntax.xml @@ -481,7 +481,7 @@ - + The parameters this function declares. @@ -505,13 +505,13 @@ - + A single parameter in a function parameter list. - + The this parameter at the first place in a parameter list. @@ -524,7 +524,7 @@ - + A single parameter in a function parameter list. diff --git a/src/Draco.LanguageServer/Capabilities/Rename.cs b/src/Draco.LanguageServer/Capabilities/Rename.cs index 33d492796..c756325cf 100644 --- a/src/Draco.LanguageServer/Capabilities/Rename.cs +++ b/src/Draco.LanguageServer/Capabilities/Rename.cs @@ -85,7 +85,7 @@ private static IEnumerable FindAllAppearances( private static Lsp.Model.TextEdit RenameNode(SyntaxNode original, string name) => original switch { - ParameterSyntax p => RenameToken(p.Name, name), + NormalParameterSyntax p => RenameToken(p.Name, name), GenericParameterSyntax g => RenameToken(g.Name, name), FunctionDeclarationSyntax f => RenameToken(f.Name, name), VariableDeclarationSyntax v => RenameToken(v.Name, name),