Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User defined classes #478

Open
wants to merge 113 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
0c3f5ca
Syntax
Kuinox Aug 18, 2024
c2ebad1
wip
Kuinox Aug 25, 2024
451df51
wip
Kuinox Sep 8, 2024
6c1f7d5
wip
Kuinox Sep 14, 2024
56e59d2
Merge remote-tracking branch 'origin/main' into userdefined-classes-3
Kuinox Sep 15, 2024
43adfa0
wip
Kuinox Sep 16, 2024
a0cab5b
wip
Kuinox Sep 16, 2024
616ad18
yes there is no message commit because it will get squashed
Kuinox Sep 17, 2024
8b6c184
progress.
Kuinox Sep 18, 2024
c1b941e
binding & symbols works.
Kuinox Sep 19, 2024
242d9b8
wip
Kuinox Sep 23, 2024
991e13d
wip
Kuinox Sep 28, 2024
73e6a15
fix
Kuinox Sep 30, 2024
231feb2
wip
Kuinox Oct 2, 2024
a839616
updated SyntaxFactory.
Kuinox Oct 3, 2024
0521fa4
ps swap.
Kuinox Oct 3, 2024
3c63845
use field keyword.
Kuinox Oct 3, 2024
ca84c41
wip
Kuinox Oct 5, 2024
23c9817
Merge remote-tracking branch 'origin/userdefined-classes-3' into user…
Kuinox Oct 5, 2024
0476eac
wip
Kuinox Oct 5, 2024
940f5f8
starting to implementing this.
Kuinox Oct 7, 2024
929d875
fix
Kuinox Oct 8, 2024
4d404ab
wip
Kuinox Oct 8, 2024
c7673ef
wip
Kuinox Oct 9, 2024
da57abc
wip
Kuinox Oct 14, 2024
2d3aaa9
Fixed MetadataCodegen
Kuinox Oct 14, 2024
712558b
Fix some codegen
Kuinox Oct 14, 2024
568c527
some progress.
Kuinox Oct 17, 2024
d798797
wip
Kuinox Oct 17, 2024
5f22300
wip
Kuinox Oct 20, 2024
abd2580
wip
Kuinox Oct 21, 2024
c25ca7f
Make constructor generate (but incorrectly)
Kuinox Oct 22, 2024
71f8162
constructor have a special name.
Kuinox Oct 23, 2024
67b98dc
it work.
Kuinox Oct 23, 2024
f4f5e0f
ok there is a few bugs remaining
Kuinox Oct 23, 2024
a6d119d
tests cleanup.
Kuinox Oct 24, 2024
2c93d54
remove debug dll dump
Kuinox Oct 24, 2024
1a0a5b7
Merge branch 'main' into userdefined-classes-3
Kuinox Oct 26, 2024
a2a35db
wip fixing tests.
Kuinox Oct 26, 2024
2ff6b99
fixed special name logic
Kuinox Oct 27, 2024
f7539df
self review
Kuinox Oct 27, 2024
8035ae4
Some pr feedback.
Kuinox Oct 27, 2024
fb297e0
Removed unused field ir model.
Kuinox Oct 27, 2024
56fd7f4
Type => Class, + ran namespace simplification.
Kuinox Oct 27, 2024
0922f74
using cleanup.
Kuinox Oct 27, 2024
5fe55ad
some pr feedback.
Kuinox Oct 28, 2024
cb8465a
more pr feedback
Kuinox Oct 28, 2024
c24b819
wip
Kuinox Oct 28, 2024
ce72219
Added error on this resolution.
Kuinox Oct 29, 2024
4de8931
Update src/Draco.Compiler/Internal/OptimizingIr/Model/Class.cs
Kuinox Oct 29, 2024
a18510d
Update src/Draco.Compiler/Internal/Syntax/Syntax.xml
Kuinox Oct 29, 2024
5db5309
Update src/Draco.Compiler/Internal/OptimizingIr/Model/Procedure.cs
Kuinox Oct 29, 2024
2bdf4ac
Added tests for illegal this.
Kuinox Oct 30, 2024
14a8df1
Merge branch 'main' into userdefined-classes-3
LPeter1997 Oct 30, 2024
4b83f01
Update Syntax.xml
LPeter1997 Oct 30, 2024
e20a311
Builds
LPeter1997 Oct 30, 2024
d696448
Update Parser.cs
LPeter1997 Oct 30, 2024
e3dd5d0
Update Parser.cs
LPeter1997 Oct 30, 2024
81a95ab
Update Parser.cs
LPeter1997 Oct 30, 2024
261b076
Update Lexer.cs
LPeter1997 Oct 30, 2024
541f941
Yeeted unit
LPeter1997 Oct 30, 2024
d6f7b4e
Update ConstructorFunctionSymbol.cs
LPeter1997 Oct 31, 2024
dafd12c
Update SyntaxErrors.cs
LPeter1997 Oct 31, 2024
883abbe
Update Lexer.cs
LPeter1997 Oct 31, 2024
1990d06
Cleaned up syntax naming
LPeter1997 Oct 31, 2024
ae6d486
Syntax fixup
LPeter1997 Oct 31, 2024
1d0e05f
Parser done
LPeter1997 Oct 31, 2024
e987b77
Some PR feedback.
Kuinox Nov 1, 2024
fbbffa9
Update DefaultConstructorSymbol.cs
LPeter1997 Nov 2, 2024
0cd287e
Update SourceThisParameterSymbol.cs
LPeter1997 Nov 2, 2024
35e0a51
Simplification
LPeter1997 Nov 2, 2024
bb06a72
More simplification
LPeter1997 Nov 2, 2024
7072883
Placed additional symbols into respective class
LPeter1997 Nov 2, 2024
9482eba
Update SyntaxFactory.cs
LPeter1997 Nov 3, 2024
6f3ae69
Update ErrorThisParameterSymbol.cs
LPeter1997 Nov 3, 2024
5c49194
Update ErrorThisParameterSymbol.cs
LPeter1997 Nov 3, 2024
312be23
Tweaks
LPeter1997 Nov 3, 2024
5d32842
Update SemanticModel.cs
LPeter1997 Nov 3, 2024
37c5f9a
Update Binder_Expression.cs
LPeter1997 Nov 3, 2024
a32b6c7
Update SourceClassSymbol.cs
LPeter1997 Nov 3, 2024
ff3636c
Update ClassBinder.cs
LPeter1997 Nov 3, 2024
3178f1b
Update ClassBinder.cs
LPeter1997 Nov 3, 2024
91db04d
Simplified
LPeter1997 Nov 3, 2024
498fd58
Update BinderCache.cs
LPeter1997 Nov 3, 2024
b10833e
Update MetadataCodegen.cs
LPeter1997 Nov 7, 2024
8d7c65b
Update MetadataCodegen.cs
LPeter1997 Nov 7, 2024
f46bb86
Update ModelExtensions.cs
LPeter1997 Nov 7, 2024
06dad34
Update Procedure.cs
LPeter1997 Nov 7, 2024
01ae05d
Removed parent relationships
LPeter1997 Nov 7, 2024
27f3e2f
Update MetadataCodegen.cs
LPeter1997 Nov 7, 2024
2155163
Update IClass.cs
LPeter1997 Nov 7, 2024
3a8e650
Update Module.cs
LPeter1997 Nov 7, 2024
b21515f
Rename
LPeter1997 Nov 7, 2024
cca9b52
Reorder, rename
LPeter1997 Nov 11, 2024
3842497
Fixed errors
LPeter1997 Nov 11, 2024
05793a9
Update ParserTests.cs
LPeter1997 Nov 11, 2024
f054f7b
Update CompilingCodeTests.cs
LPeter1997 Nov 11, 2024
0d44315
Update ConstructorFunctionSymbol.cs
LPeter1997 Nov 11, 2024
50bc7fb
Made class props work
LPeter1997 Nov 11, 2024
fc64a4d
Update SourceClassSymbol.cs
LPeter1997 Nov 11, 2024
4a7df1a
Update MetadataCodegen.cs
LPeter1997 Nov 11, 2024
3d8db0c
Slight fixes
LPeter1997 Nov 11, 2024
f0526b6
Fix
LPeter1997 Nov 12, 2024
d418c40
Codegen and IR fix
LPeter1997 Nov 12, 2024
02ed123
Update MetadataCodegen.cs
LPeter1997 Nov 13, 2024
3429e63
Update MetadataCodegen.cs
LPeter1997 Nov 13, 2024
a42b49f
Update MetadataCodegen.cs
LPeter1997 Nov 13, 2024
4e71a87
Update MetadataCodegen.cs
LPeter1997 Nov 13, 2024
a6a5d9e
Update MetadataCodegen.cs
LPeter1997 Nov 14, 2024
1b79b58
Simplification
LPeter1997 Nov 18, 2024
bf23220
Update MetadataCodegen.cs
LPeter1997 Nov 18, 2024
670c6d4
Naming fixes
LPeter1997 Nov 19, 2024
0bbfb53
Tests pass
LPeter1997 Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Draco.Chr/Constraints/PropagationHistory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Draco.Chr.Rules;
Expand Down
1 change: 0 additions & 1 deletion src/Draco.Compiler.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.CommandLine;
using System.CommandLine.Parsing;
using System.IO;
using System.Linq;
using Draco.Compiler.Api;
Expand Down
48 changes: 48 additions & 0 deletions src/Draco.Compiler.Tests/EndToEnd/CompilingCodeTests.cs
Kuinox marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -999,4 +999,52 @@ func outer(x: int32): int32 {

Assert.Equal(3, result);
}

[Fact]
public void ClassHelloWorld()
{
var assembly = CompileToAssembly("""
import System.Console;

class Foo {
func bar() {
WriteLine("Hello, World!");
}
}
""");

var stringWriter = new StringWriter();
_ = Invoke<object?>(assembly: assembly, stdout: stringWriter, methodName: "bar", moduleName: "FreeFunctions.Foo");

Assert.Equal($"Hello, World!{Environment.NewLine}", stringWriter.ToString(), ignoreLineEndingDifferences: true);
}

[Fact]
public void InstanceField()
{
var assembly = CompileToAssembly("""
import System.Console;

func main(): int32 {
var foo = Foo();
foo.increment();
return foo.get();
}

class Foo {
field var i: int32;
public func increment(this) {
this.i += 1;
}

public func get(this): int32 {
return this.i;
}
}
""");

var stringWriter = new StringWriter();
var value = Invoke<int>(assembly: assembly, stdout: stringWriter);
Assert.Equal(1, value);
}
}
4 changes: 2 additions & 2 deletions src/Draco.Compiler.Tests/Semantics/AttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())));

Expand Down Expand Up @@ -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())));

Expand Down
22 changes: 11 additions & 11 deletions src/Draco.Compiler.Tests/Semantics/ControlFlowGraphTests.cs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should sync this after props are merged, as we got nicer factories for these

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nothing to do right now ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I'll try to get props done asap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind if you sync it.

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -119,7 +119,7 @@ public async Task WhileLoop()
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("i", null, LiteralExpression(0))),
DeclarationStatement(VariableDeclaration(true, "i", null, LiteralExpression(0))),
ExpressionStatement(WhileExpression(
RelationalExpression(NameExpression("i"), ComparisonElement(LessThan, LiteralExpression(10))),
BlockExpression(
Expand Down Expand Up @@ -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"))),
Expand Down Expand Up @@ -181,10 +181,10 @@ 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("x", null, IfExpression(
DeclarationStatement(VariableDeclaration(true, "x", null, IfExpression(
NameExpression("b"),
GotoExpression(NameLabel("noassign")),
LiteralExpression(1)))),
Expand All @@ -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);
Expand All @@ -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")),
Expand Down
38 changes: 19 additions & 19 deletions src/Draco.Compiler.Tests/Semantics/DefiniteAssignmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public void UseOfUnassignedVariable()
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", NameType("int32"))),
DeclarationStatement(VariableDeclaration("y", NameType("int32"), NameExpression("x")))))));
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))),
DeclarationStatement(VariableDeclaration(true, "y", NameType("int32"), NameExpression("x")))))));

// Act
var compilation = CreateCompilation(tree);
Expand All @@ -46,8 +46,8 @@ public void UseOfAssignedVariable()
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", NameType("int32"), LiteralExpression(0))),
DeclarationStatement(VariableDeclaration("y", NameType("int32"), NameExpression("x")))))));
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"), LiteralExpression(0))),
DeclarationStatement(VariableDeclaration(true, "y", NameType("int32"), NameExpression("x")))))));

// Act
var compilation = CreateCompilation(tree);
Expand All @@ -69,15 +69,15 @@ public void UseOfConditionallyAssignedVariable()
// }
var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration(
"foo",
ParameterList(Parameter("b", NameType("bool"))),
ParameterList(NormalParameter("b", NameType("bool"))),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", NameType("int32"))),
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))),
ExpressionStatement(IfExpression(
NameExpression("b"),
StatementExpression(ExpressionStatement(BinaryExpression(NameExpression("x"), Assign, LiteralExpression(42)))),
null as ExpressionSyntax)),
DeclarationStatement(VariableDeclaration("y", NameType("int32"), NameExpression("x")))))));
DeclarationStatement(VariableDeclaration(true, "y", NameType("int32"), NameExpression("x")))))));

// Act
var compilation = CreateCompilation(tree);
Expand All @@ -100,15 +100,15 @@ public void UseOfConditionallyAssignedVariableOnBothBranches()
// }
var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration(
"foo",
ParameterList(Parameter("b", NameType("bool"))),
ParameterList(NormalParameter("b", NameType("bool"))),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", NameType("int32"))),
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))),
ExpressionStatement(IfExpression(
NameExpression("b"),
BinaryExpression(NameExpression("x"), Assign, LiteralExpression(42)),
BinaryExpression(NameExpression("x"), Assign, LiteralExpression(0)))),
DeclarationStatement(VariableDeclaration("y", NameType("int32"), NameExpression("x")))))));
DeclarationStatement(VariableDeclaration(true, "y", NameType("int32"), NameExpression("x")))))));

// Act
var compilation = CreateCompilation(tree);
Expand All @@ -130,15 +130,15 @@ public void JumpingMidAssignment()
// }
var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration(
"foo",
ParameterList(Parameter("b", NameType("bool"))),
ParameterList(NormalParameter("b", NameType("bool"))),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", NameType("int32"), IfExpression(
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"), IfExpression(
NameExpression("b"),
GotoExpression(NameLabel("end")),
LiteralExpression(42)))),
DeclarationStatement(LabelDeclaration("end")),
DeclarationStatement(VariableDeclaration("y", NameType("int32"), NameExpression("x")))))));
DeclarationStatement(VariableDeclaration(true, "y", NameType("int32"), NameExpression("x")))))));

// Act
var compilation = CreateCompilation(tree);
Expand All @@ -163,7 +163,7 @@ public void CompoundAssigningUnassignedVariable()
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", NameType("int32"))),
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))),
ExpressionStatement(BinaryExpression(NameExpression("x"), PlusAssign, LiteralExpression(42)))))));

// Act
Expand All @@ -189,14 +189,14 @@ public void UseVariableAssignedLater()
// }
var tree = SyntaxTree.Create(CompilationUnit(FunctionDeclaration(
"foo",
ParameterList(Parameter("b", NameType("bool"))),
ParameterList(NormalParameter("b", NameType("bool"))),
null,
BlockFunctionBody(
ExpressionStatement(WhileExpression(
NameExpression("b"),
BlockExpression(
DeclarationStatement(VariableDeclaration("x", NameType("int32"))),
DeclarationStatement(VariableDeclaration("y", NameType("int32"), NameExpression("x"))),
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))),
DeclarationStatement(VariableDeclaration(true, "y", NameType("int32"), NameExpression("x"))),
ExpressionStatement(BinaryExpression(NameExpression("x"), Assign, LiteralExpression(42))))))))));

// Act
Expand All @@ -215,7 +215,7 @@ public void GlobalImmutableInitialized()
// Arrange
// val x: int32 = 0;
var tree = SyntaxTree.Create(CompilationUnit(
ImmutableVariableDeclaration("x", NameType("int32"), LiteralExpression(0))));
ImmutableVariableDeclaration(true, "x", NameType("int32"), LiteralExpression(0))));

// Act
var compilation = CreateCompilation(tree);
Expand All @@ -232,7 +232,7 @@ public void GlobalImmutableNotInitialized()
// Arrange
// val x: int32;
var tree = SyntaxTree.Create(CompilationUnit(
ImmutableVariableDeclaration("x", NameType("int32"))));
ImmutableVariableDeclaration(true, "x", NameType("int32"))));

// Act
var compilation = CreateCompilation(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void VariableDocumentationComment(string docComment)
// Arrange
var tree = SyntaxTree.Create(CompilationUnit(
WithDocumentation(VariableDeclaration(
true,
"x",
null,
LiteralExpression(0)),
Expand Down Expand Up @@ -169,14 +170,14 @@ public void ModuleDocumentationComment(string docComment)
var tree = SyntaxTree.Create(CompilationUnit(
WithDocumentation(ModuleDeclaration(
"documentedModule",
VariableDeclaration(Api.Semantics.Visibility.Public, "Foo", null, LiteralExpression(0))),
VariableDeclaration(Api.Semantics.Visibility.Public, true, "Foo", null, LiteralExpression(0))),
docComment),
FunctionDeclaration(
"foo",
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", null, MemberExpression(NameExpression("documentedModule"), "Foo")))))));
DeclarationStatement(VariableDeclaration(true, "x", null, MemberExpression(NameExpression("documentedModule"), "Foo")))))));

var moduleRef = tree.GetNode<MemberExpressionSyntax>(0).Accessed;

Expand Down Expand Up @@ -283,7 +284,7 @@ public void StaticTypeDocumentationFromMetadata()
"main",
ParameterList(),
null,
BlockFunctionBody(DeclarationStatement(VariableDeclaration("x", null, MemberExpression(NameExpression("TestClass"), "foo")))))));
BlockFunctionBody(DeclarationStatement(VariableDeclaration(true, "x", null, MemberExpression(NameExpression("TestClass"), "foo")))))));

var docs = "<summary> Documentation for TestClass </summary>";

Expand Down Expand Up @@ -566,7 +567,7 @@ namespace TestNamespace;
public class TestClass
{
{{CreateXmlDocComment(originalDocs)}}
public int TestMethod<T>(int arg1, int arg2) => arg1 + arg2;
public int TestMethod<T>(int arg1, int arg2) => arg1 + arg2;
}
""", xmlDocStream: xmlStream);

Expand Down
19 changes: 10 additions & 9 deletions src/Draco.Compiler.Tests/Semantics/LocalFunctionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParameterSyntax>(0);
var x2Decl = tree.GetNode<ParameterSyntax>(1);
var x1Decl = tree.GetNode<NormalParameterSyntax>(0);
var x2Decl = tree.GetNode<NormalParameterSyntax>(1);

// Act
var compilation = CreateCompilation(tree);
Expand Down Expand Up @@ -66,7 +66,7 @@ public void UndefinedReference()
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("y", null, NameExpression("x"))))))))));
DeclarationStatement(VariableDeclaration(true, "y", null, NameExpression("x"))))))))));

// Act
var compilation = CreateCompilation(tree);
Expand Down Expand Up @@ -98,6 +98,7 @@ public void LocalVariableIncompatibleType()
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration(
true,
"x",
NameType("int32"),
StringExpression("Hello"))))))))));
Expand Down Expand Up @@ -160,8 +161,8 @@ public void ReferenceUninitializedVariable()
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration("x", NameType("int32"))),
DeclarationStatement(VariableDeclaration("y", null, NameExpression("x"))))))))));
DeclarationStatement(VariableDeclaration(true, "x", NameType("int32"))),
DeclarationStatement(VariableDeclaration(true, "y", null, NameExpression("x"))))))))));

// Act
var compilation = CreateCompilation(tree);
Expand Down Expand Up @@ -189,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(
Expand All @@ -199,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))),
Expand Down
Loading
Loading