Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TypeCheckingTests.cs
Browse files Browse the repository at this point in the history
LPeter1997 committed Oct 16, 2023
1 parent bba90b4 commit bde7d25
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs
Original file line number Diff line number Diff line change
@@ -2221,4 +2221,32 @@ public static class FooModule{
Assert.Empty(diags);
Assert.Equal("System.Random", xSym.Type.FullName);
}

[Fact]
public void StringAssignableToObject()
{
// func main(){
// var x: object = "Hello";
// }

var main = SyntaxTree.Create(CompilationUnit(FunctionDeclaration(
"main",
ParameterList(),
null,
BlockFunctionBody(
DeclarationStatement(VariableDeclaration(
"x",
NameType("object"),
StringExpression("Hello")))))));

// Act
var compilation = CreateCompilation(main);

var semanticModel = compilation.GetSemanticModel(main);

var diags = semanticModel.Diagnostics;

// Assert
Assert.Empty(diags);
}
}

0 comments on commit bde7d25

Please sign in to comment.