From bde7d25ddc2c23010c07cae0fa5213e6ee2617e7 Mon Sep 17 00:00:00 2001 From: LPeter1997 Date: Mon, 16 Oct 2023 17:52:28 +0200 Subject: [PATCH] Update TypeCheckingTests.cs --- .../Semantics/TypeCheckingTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs b/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs index 8fd15c8bd..12e130589 100644 --- a/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs @@ -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); + } }