Draco-lang / Compiler

The compiler repository for the Draco programming language.
Apache License 2.0
103 stars 8 forks source link

Some exceptions when compiling some snippets. #139

Open Kuinox opened 1 year ago

Kuinox commented 1 year ago

This issue purpose is to gather parser exceptions that are throwed when parsing snippets of code. Follow the following pattern:

func main() {
    var i = 0;
    println("Hello! \{}");
}

Exception:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'expr')
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Editor.Web.Program.DisplayCompiledCSharp(Compilation compilation)
   at Draco.Editor.Web.Program.ProcessUserInput()

Playground

Kuinox commented 1 year ago

Another snippet, another bug:

func main() {
    var i = 0;
    println(i.ToString());
}

Exception:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'expr')
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitCallExpr(Call node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExpr(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitPunctuated[Expr](Punctuated`1 punctuated)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitPunctuatedList[Expr](PunctuatedList`1 list)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitEnclosed[Expr](Enclosed`1 enclosed)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitCallExpr(Call node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitCallExpr(Call node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExpr(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExprStmt(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitStmt(Stmt node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitImmutableArray[Stmt](ImmutableArray`1 elements)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockContents(BlockContents node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitEnclosed[BlockContents](Enclosed`1 enclosed)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockExpr(Block node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockBodyFuncBody(BlockBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncBody(FuncBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncDecl(Func node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitFuncDecl(Func node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.Infer(ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c.<InferLocalTypes>b__5_1(TypeInferenceVisitor visitor, ParseTree tree)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceResult, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(TypeInferenceVisitor ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[TypeInferenceVisitor,TypeInferenceResult](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ParseTree,TypeInferenceVisitor,TypeInferenceResult](ParseTree args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.InferLocalTypes(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Editor.Web.Program.DisplayCompiledCSharp(Compilation compilation)
   at Draco.Editor.Web.Program.ProcessUserInput()

Playground

Kuinox commented 1 year ago

Another snippet:

func main() {
    var i = i + 
}
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'expr')
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitBinaryExpr(Binary node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExpr(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitValueInitializer(ValueInitializer node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitVariableDecl(Variable node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitVariableDecl(Variable node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDeclStmt(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitStmt(Stmt node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitImmutableArray[Stmt](ImmutableArray`1 elements)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockContents(BlockContents node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitEnclosed[BlockContents](Enclosed`1 enclosed)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockExpr(Block node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockBodyFuncBody(BlockBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncBody(FuncBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncDecl(Func node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitFuncDecl(Func node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.Infer(ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c.<InferLocalTypes>b__5_1(TypeInferenceVisitor visitor, ParseTree tree)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceResult, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(TypeInferenceVisitor ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[TypeInferenceVisitor,TypeInferenceResult](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ParseTree,TypeInferenceVisitor,TypeInferenceResult](ParseTree args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.InferLocalTypes(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Editor.Web.Program.DisplayCompiledCSharp(Compilation compilation)
   at Draco.Editor.Web.Program.ProcessUserInput()

Playground

Binto86 commented 1 year ago

Another error when there is missing type anotation

func main():{}
System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c__DisplayClass1_0.<Evaluate>b__0(TypeExpr expr)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.TypeExpr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, TypeExpr a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.TypeExpr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Type](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[TypeExpr,Unit,Type](TypeExpr args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[TypeExpr,Type](TypeExpr args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.Evaluate(QueryDatabase db, TypeExpr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitFuncDecl(Func node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.Infer(ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c.<InferLocalTypes>b__5_1(TypeInferenceVisitor visitor, ParseTree tree)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceResult, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(TypeInferenceVisitor ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[TypeInferenceVisitor,TypeInferenceResult](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ParseTree,TypeInferenceVisitor,TypeInferenceResult](ParseTree args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.InferLocalTypes(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream csStream, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute[Object](Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute(Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)

Playground

Binto86 commented 1 year ago

Another bug

func main(){
    return;
}
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'expr')
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass3_0.<ToAst>b__0(Expr expr)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, Expr a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Expr](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Expr,Unit,Expr](Expr args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Expr,Expr](Expr args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.ToAst(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass2_0.<ToAst>b__0(Stmt stmt)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, Stmt a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Stmt](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Stmt,Unit,Stmt](Stmt args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Stmt,Stmt](Stmt args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.ToAst(QueryDatabase db, Stmt stmt)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass3_0.<ToAst>b__1(Stmt s)
   at System.Linq.Enumerable.SelectArrayIterator`2[[Draco.Compiler.Api.Syntax.ParseTree.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Stmt](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Stmt](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Stmt](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Stmt](IEnumerable`1 items)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass3_0.<ToAst>b__0(Expr expr)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, Expr a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Expr](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Expr,Unit,Expr](Expr args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Expr,Expr](Expr args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.ToAst(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass5_0.<ToAst>b__0(FuncBody funcBody)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.FuncBody, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr.Block, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, FuncBody a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.FuncBody, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr.Block, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Block](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[FuncBody,Unit,Block](FuncBody args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[FuncBody,Block](FuncBody args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.ToAst(QueryDatabase db, FuncBody funcBody)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass1_0.<ToAst>b__0(Decl decl)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, Decl a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Decl](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Decl,Unit,Decl](Decl args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[Decl,Decl](Decl args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.ToAst(QueryDatabase db, Decl decl)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass4_0.<ToAst>b__1(Decl d)
   at System.Linq.Enumerable.SelectArrayIterator`2[[Draco.Compiler.Api.Syntax.ParseTree.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Decl](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Decl](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Decl](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Decl](IEnumerable`1 items)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.<>c__DisplayClass4_0.<ToAst>b__0(CompilationUnit cu)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.CompilationUnit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.CompilationUnit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, CompilationUnit a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.CompilationUnit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.CompilationUnit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,CompilationUnit](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[CompilationUnit,Unit,CompilationUnit](CompilationUnit args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[CompilationUnit,CompilationUnit](CompilationUnit args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.ToAst(QueryDatabase db, CompilationUnit cu)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstBuilder.ToAst(QueryDatabase db, ParseTree ast)
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream csStream, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute[Object](Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute(Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)

Playground

thinker227 commented 1 year ago

Exception when creating a function with two parameters of the same type and name and then calling the function.

func main() {
    val x = foo("a", "b");
    println(x);
}

func foo(x: string, x: string): string = x;
System.InvalidOperationException: can't compare type variables
   at Draco.Compiler.Internal.Semantics.Types.Type.Variable.Equals(Variable other)
   at Draco.Compiler.Internal.Semantics.Types.Type.Variable.Equals(Object obj)
   at Draco.Compiler.Internal.Semantics.Types.Type.Variable.Equals(Type other)
   at Draco.Compiler.Internal.Codegen.CSharpCodegen.IsUnit(Type type)
   at Draco.Compiler.Internal.Codegen.CSharpCodegen.DefineRegister(Type type, String name, String expr)
   at Draco.Compiler.Internal.Codegen.CSharpCodegen.VisitVariableDecl(Variable node)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstVisitorBase`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitDecl(Decl node)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstVisitorBase`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitDeclStmt(Decl node)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstVisitorBase`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitStmt(Stmt node)
   at Draco.Compiler.Internal.Codegen.CSharpCodegen.VisitBlockExpr(Block node)
   at Draco.Compiler.Internal.Codegen.CSharpCodegen.VisitFuncDecl(Func node)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstVisitorBase`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitDecl(Decl node)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstVisitorBase`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitImmutableArray(ImmutableArray`1 decls)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstVisitorBase`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCompilationUnit(CompilationUnit node)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.AstVisitorBase`1[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Visit(Ast node)
   at Draco.Compiler.Internal.Codegen.CSharpCodegen.Generate(Ast root)
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream csStream, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute[Object](Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute(Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)

Playground

thinker227 commented 1 year ago

Exception when referencing an unknown type in either the return type or a parameter type of a function.

func foo(): Foo = x;
System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c__DisplayClass1_0.<Evaluate>b__0(TypeExpr expr)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ParseTree.TypeExpr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, TypeExpr a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree.TypeExpr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Type](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[TypeExpr,Unit,Type](TypeExpr args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[TypeExpr,Type](TypeExpr args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.Evaluate(QueryDatabase db, TypeExpr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitFuncDecl(Func node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.Infer(ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c.<InferLocalTypes>b__5_1(TypeInferenceVisitor visitor, ParseTree tree)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceResult, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(TypeInferenceVisitor ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[TypeInferenceVisitor,TypeInferenceResult](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ParseTree,TypeInferenceVisitor,TypeInferenceResult](ParseTree args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.InferLocalTypes(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream csStream, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute[Object](Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute(Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)

Playground

Kuinox commented 1 year ago
func main(a: int32) {}
error: roslyn reported an error while compiling the generated C# code The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
error: roslyn reported an error while compiling the generated C# code There is no argument given that corresponds to the required formal parameter 'sym_1' of 'DracoProgram.main(int)'

Playground

Kuinox commented 1 year ago
func main() {
    println(b("1"));
}

var b= "2";
func b(b:string):string { return b; }
error: roslyn reported an error while compiling the generated C# code The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
error: roslyn reported an error while compiling the generated C# code The type 'DracoProgram' already contains a definition for 'b'
error: roslyn reported an error while compiling the generated C# code Cannot assign to 'b' because it is a 'method group'
error: roslyn reported an error while compiling the generated C# code Field 'DracoProgram.b' is never assigned to, and will always have its default value null

Playground

Kuinox commented 1 year ago
func main() {
    println(a("1"));
}

func a(a: string):string {}
error: roslyn reported an error while compiling the generated C# code The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
error: roslyn reported an error while compiling the generated C# code 'DracoProgram.a(string)': not all code paths return a value

Playground

LPeter1997 commented 1 year ago
func main() {
    var 
    println("");
}
thinker227 commented 1 year ago

Assigning to a type or referencing a type in place of a variable in general.

func main() {
    int32 = 0;
}

Playground

func main(): int32 {
    return int32;
}

Playground

System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, ISymbol symbol)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitBinaryExpr(Binary node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExpr(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExprStmt(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitStmt(Stmt node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitImmutableArray[Stmt](ImmutableArray`1 elements)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockContents(BlockContents node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitEnclosed[BlockContents](Enclosed`1 enclosed)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockExpr(Block node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockBodyFuncBody(BlockBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncBody(FuncBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncDecl(Func node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitFuncDecl(Func node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseTree node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.Infer(ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c.<InferLocalTypes>b__5_1(TypeInferenceVisitor visitor, ParseTree tree)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceResult, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(TypeInferenceVisitor ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[TypeInferenceVisitor,TypeInferenceResult](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ParseTree,TypeInferenceVisitor,TypeInferenceResult](ParseTree args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.InferLocalTypes(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseTree tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseTree, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|8_0(ParseTree tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream csStream, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute[Object](Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute(Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)
thinker227 commented 1 year ago
val x = x;

Playground

System.InvalidOperationException: Cycle detected:
 * TypeOf [Draco.Compiler.Internal.Semantics.Symbols.ISymbol+Variable]
 * InferLocalTypes [val x = x;]
 * TypeOf [Draco.Compiler.Internal.Semantics.Symbols.ISymbol+Variable]
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Type](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ITyped,Unit,Type](ITyped args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ITyped,Type](ITyped args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, ISymbol symbol)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitVariableDecl(Variable node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseNode node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.Infer(ParseNode tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c.<InferLocalTypes>b__5_1(TypeInferenceVisitor visitor, ParseNode tree)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseNode, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceResult, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(TypeInferenceVisitor ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[TypeInferenceVisitor,TypeInferenceResult](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ParseNode,TypeInferenceVisitor,TypeInferenceResult](ParseNode args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.InferLocalTypes(QueryDatabase db, ParseNode tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c__DisplayClass3_0.<TypeOf>b__0(ITyped typed)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Internal.Semantics.Symbols.ISymbol.ITyped, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, ITyped a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Internal.Semantics.Symbols.ISymbol.ITyped, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Type](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ITyped,Unit,Type](ITyped args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ITyped,Type](ITyped args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, ISymbol symbol)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseNode tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|10_0(ParseNode tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseNode, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|10_0(ParseNode tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.EmitCSharp(Stream csStream)
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream csStream, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute[Object](Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute(Compilation compilation, Func`2 csCompilerOptionBuilder)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)
Binto86 commented 1 year ago
func main() {
    println(0.1);
}

Playground

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'expr')
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.TypeOf(QueryDatabase db, Expr expr)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.<>c__DisplayClass24_0.<VisitCallExpr>b__0(Punctuated`1 a)
   at System.Linq.Enumerable.SelectArrayIterator`2[[Draco.Compiler.Api.Syntax.ParseNode.Punctuated`1[[Draco.Compiler.Api.Syntax.ParseNode.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Internal.Semantics.Types.Type, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Type](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Type](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Type](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Type](IEnumerable`1 items)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitCallExpr(Call node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExpr(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitExprStmt(Expr node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitStmt(Stmt node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseNode node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitImmutableArray[Stmt](ImmutableArray`1 elements)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockContents(BlockContents node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseNode node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitEnclosed[BlockContents](Enclosed`1 enclosed)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockExpr(Block node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitBlockBodyFuncBody(BlockBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncBody(FuncBody node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitFuncDecl(Func node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.VisitFuncDecl(Func node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].VisitDecl(Decl node)
   at Draco.Compiler.Api.Syntax.ParseTreeVisitorBase`1[[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Visit(ParseNode node)
   at Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor.Infer(ParseNode tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.<>c.<InferLocalTypes>b__5_1(TypeInferenceVisitor visitor, ParseNode tree)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ParseNode, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceVisitor, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.Types.TypeInferenceResult, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(TypeInferenceVisitor ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[TypeInferenceVisitor,TypeInferenceResult](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ParseNode,TypeInferenceVisitor,TypeInferenceResult](ParseNode args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.InferLocalTypes(QueryDatabase db, ParseNode tree)
   at Draco.Compiler.Internal.Semantics.Types.TypeChecker.GetDiagnostics(QueryDatabase db, ParseNode tree)
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|10_0(ParseNode tree)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.ParseNode, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Draco.Compiler.Api.Semantics.SemanticModel.<GetAllDiagnostics>g__Impl|10_0(ParseNode tree)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream dracoIrStream)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute[Object](Compilation compilation)
   at Draco.Compiler.Api.Scripting.ScriptingEngine.Execute(Compilation compilation)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)
LPeter1997 commented 1 year ago
func main() {
    1 = 1;
}
LPeter1997 commented 1 year ago
func foo(): int32 {
    if ({ return 4 }) {
        if (true) {
            return 0;
        }
        else {
            return 1;
        }
    }
}
Binto86 commented 1 year ago
func main(){
    println(foo());
}

func foo(): string{
    "1+2"
}
Binto86 commented 1 year ago
func main(){
    println("1 + 2 = \{1 + 2}");
}

Playground

LPeter1997 commented 1 year ago
func foo() {
    if (false) {
    lbl:
        return;
    }
    while (false) {
        goto lbl;
    }
}
Binto86 commented 1 year ago
func main() {
    ;
}

Playground

Binto86 commented 1 year ago
func main()
}

Playground

Binto86 commented 1 year ago
func main(){
    var x;
    x = x();
}
Binto86 commented 1 year ago
func main() {
    func 
}
Binto86 commented 1 year ago
func main() {
    println[]
}
Kuinox commented 1 year ago

https://playground.draco-lang.org/#AksrzUtWyE3MzNPQVKjmUgCCgqLMvJKcPA0l9cSSEvUSJXWlEnX1_KJsayVNa65aLgA=

func main() {
    println("'att't"'"t''ork;");
}
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at Draco.Compiler.Api.Syntax.SyntaxNode.TranslateRelativeRange(RelativeRange range)
   at Draco.Compiler.Internal.Diagnostics.Location.RelativeToTree.ToApiLocation(SyntaxNode context)
   at Draco.Compiler.Internal.Diagnostics.Diagnostic.ToApiDiagnostic(SyntaxNode context)
   at Draco.Compiler.Api.Syntax.SyntaxTree.<>c__DisplayClass13_0.<get_Diagnostics>b__1(Diagnostic d)
   at System.Linq.Enumerable.SelectListIterator`2[[Draco.Compiler.Internal.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2[[Draco.Compiler.Api.Syntax.SyntaxNode, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Api.Diagnostics.Diagnostic, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Diagnostic](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Diagnostic](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Diagnostic](IEnumerable`1 items)
   at Draco.Compiler.Api.Compilation.GetSyntaxDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream dracoIrStream)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)
Kuinox commented 1 year ago

https://playground.draco-lang.org/#AksrzUtWyE3MzNPQVKjmUgCCgqLMvJKcPA0l9cSSEvUSJXUl9fyibGslTWuuWi4A

func main() {
    println("'att't"'"'ork;");
}
System.NotImplementedException: The method or operation is not implemented.
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAstExpr(LiteralExpressionSyntax lit)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.<>c__DisplayClass3_0.<ToAstExpr>b__0(ExpressionSyntax expr)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.ExpressionSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, ExpressionSyntax a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.ExpressionSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Expr](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ExpressionSyntax,Unit,Expr](ExpressionSyntax args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[ExpressionSyntax,Expr](ExpressionSyntax args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAstExpr(QueryDatabase db, ExpressionSyntax expr)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.<>c__DisplayClass2_0.<ToAstStmt>b__0(StatementSyntax stmt)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.StatementSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, StatementSyntax a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.StatementSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Stmt, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Stmt](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[StatementSyntax,Unit,Stmt](StatementSyntax args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[StatementSyntax,Stmt](StatementSyntax args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAstStmt(QueryDatabase db, StatementSyntax stmt)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAstFuncBody(QueryDatabase db, BlockFunctionBodySyntax body)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.<>c__DisplayClass6_0.<ToAstFuncBody>b__0(FunctionBodySyntax funcBody)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.FunctionBodySyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr.Block, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, FunctionBodySyntax a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.FunctionBodySyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Expr.Block, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Block](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[FunctionBodySyntax,Unit,Block](FunctionBodySyntax args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[FunctionBodySyntax,Block](FunctionBodySyntax args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAstFuncBody(QueryDatabase db, FunctionBodySyntax funcBody)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.<>c__DisplayClass1_0.<ToAstDecl>b__0(DeclarationSyntax decl)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.DeclarationSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, DeclarationSyntax a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.DeclarationSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,Decl](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[DeclarationSyntax,Unit,Decl](DeclarationSyntax args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[DeclarationSyntax,Decl](DeclarationSyntax args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAstDecl(QueryDatabase db, DeclarationSyntax decl)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.<>c__DisplayClass5_0.<ToAstCompilationUnit>b__1(DeclarationSyntax d)
   at System.Linq.Enumerable.SelectEnumerableIterator`2[[Draco.Compiler.Api.Syntax.DeclarationSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1[[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.Decl, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[Decl](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[Decl](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[Decl](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[Decl](IEnumerable`1 items)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.<>c__DisplayClass5_0.<ToAstCompilationUnit>b__0(CompilationUnitSyntax cu)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass4_0`2[[Draco.Compiler.Api.Syntax.CompilationUnitSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.CompilationUnit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__1(Unit _, CompilationUnitSyntax a1)
   at Draco.Compiler.Internal.Query.QueryDatabase.<>c__DisplayClass5_0`3[[Draco.Compiler.Api.Syntax.CompilationUnitSyntax, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Utilities.Unit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Draco.Compiler.Internal.Semantics.AbstractSyntax.Ast.CompilationUnit, Draco.Compiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<GetOrUpdate>b__0(Unit ctx)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdateImpl[Unit,CompilationUnit](String queryName, Object args, Func`1 createContext, Func`2 recompute, Func`2 handleCycle)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[CompilationUnitSyntax,Unit,CompilationUnit](CompilationUnitSyntax args, Func`1 createContext, Func`3 recompute, Func`3 handleCycle, String queryName)
   at Draco.Compiler.Internal.Query.QueryDatabase.GetOrUpdate[CompilationUnitSyntax,CompilationUnit](CompilationUnitSyntax args, Func`2 recompute, Func`2 handleCycle, String queryName)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAstCompilationUnit(QueryDatabase db, CompilationUnitSyntax cu)
   at Draco.Compiler.Internal.Semantics.AbstractSyntax.SyntaxTreeToAst.ToAst(QueryDatabase db, SyntaxNode ast)
   at Draco.Compiler.Api.Semantics.SemanticModel.GetAllDiagnostics()
   at Draco.Compiler.Api.Semantics.SemanticModel.get_Diagnostics()
   at Draco.Compiler.Api.Compilation.GetSemanticDiagnostics()
   at Draco.Compiler.Api.Compilation.GetDiagnostics()
   at Draco.Compiler.Api.Compilation.Emit(Stream peStream, Stream dracoIrStream)
   at Draco.Editor.Web.Program.RunScript(Compilation compilation)
Binto86 commented 1 year ago

https://playground.draco-lang.org/#Al1Ux7aqiBac8xWgoiKCCRVFMRLMB8SEEREDKGJAMOC39-l3b09eDXdYO1ZN1jvwXxC9IwXwQocAKpZHd5UT2no522wXTxtTBzPMtb_UOQ6GQsdRXQyqLiWzSXYOjcsZ6pLgx2sAdj+tXaFyETN+bgk++i5ryC3wpMaEKeQ/cGx7KY6N5/P7XcTPr/ssBO3Jt2zzSyP8zl2tvOStX+Ts00S7RH0KtGR6UMk0bsxxsrIUIGx+EiUkB9pF7Hx7tc+GGFoU1XJbK1txQJmYp1xAvy2AY1O67Jx7LLtTOsTsig+uEwR2fP38kcsObADXlqdjGIzdhBdmwhj4aaGr4f7Gb9MivlvdeHcym81iTpaJLaUEiqdRCyKp7CudZxPfgq44jaDkVuIDKv+tndG1Y9fkb0//3ZzGxZhX7OZz42V9RkcP2thAhUhpRHJScnVSIz2iY8tVcx31UOBB7AxgCCtH0O2xs+Srm2z1wdprlHcDrlGkxlVgVYEGtQLF0BRzJeTVpk5fASe3KzXce+BrneKM22k7PaMQEWs7uhQ8w9EHDtlyPWPj66/X3IGIdCizyJ7lmQTatwV/0kxgTPQROcKBT4CoDn86b2dMtDpw7aMeNpXQ6LiTi2KaxsG5BgiFugN6mEfkd/FMQ/VELmbM5D4e3vCV6PdJi3p5jn0+lGFkgmqr1KYYPltTAQF5tk6jGOobtI4sUgovP0Tjshld+kMmSpIrKt5Id5M+GDanJRgWKx+0m7YfeBmUw8P27sGqss75SSYbjA6B6Hh/Z/jdfckEVDn9pYmo2KIpd14exTXKFYl3mA22JvXyeZgXGuZaV2XRaKyUy0i8VhuFVKqScnpYYyzIHOPUw8hpqlUOqxkQ6gF05DSk7Fe2cL5oBvvVhYB7vvmrfvAvPlzxpAoJ5zav/Y8SufDU8w/rVGjxxz+tZiP+tg38Fx9kpZBQzUyklGSFU9lvZr39GcfZYAVqc9r25r/xDhgstEtgDuT6eX5RCuWYH3UE7Gcak7k9yByOskFqHZ4Cx3ZNKXQmIEZxUJn15aI8c89Rk+gPvC+ax8CeXvYh79w4Fo75pblee6NarXLX0mq3xwGfNEBq8CBZCPtOAF6MXk9tMpaYrHzGvrWxObmVtF8x9m/LHBxqcTE29PuGUoYkmKqV5v+1a4FjKYkuAEbuOV05m4Tk8SzrcXf/imPvV70lhws5c9PdiW/NFudzQV3HU6Jaf7LJub924nv4pnHYRu1KQnvWMjkLP4+uvFgk4UDo5FRzA2G/svLdB+jjcoOH0PlsR5EFDSdK4sfrn8SKL50LrHrgS4wtdpJv22jXg7SXQcZ5fIustyUfctgocHz/PIn+TP00ruRzedBGq8mG8gYD8UzmZoH/hxOxHHmK0fV1bh6Z8x2Yv/asbkasTTXG3Zglvew8f5lw80Y6Wk20nxkgCx/kVTE4j1B8spgYqfDiWV/89LxK5oltdL8vVNZm32t0uHePVy4ZHldhSdTRlapnez+fXU96le9TDK+aAZdkS+BwlKcUqhyrcolC3dvHXnc55AbTYbM3ppE5a3adDeAPKIRo33HYLh0g0CjnIaAE9LOR0tlu3YDaGSxHNmxwhCzEIT1/0QqhgZE9qOBkpbibxEbnPhI2ha8wvBRP7YrQbNS296ZlfGpOE968IbsfLTfj176EY4jkFCvfPXbcDSarHIaZBrbsAiuvLVxqKeqUqe4uBOc6o46S/qztW0QhhSirzmzp2aYk5xxUE7XdmzJZ9AKUL+Gyf5eePPr1SPaEqudvp77B++GfcxP10vfzojQ4voFGqhrv+hQdykpXESl3r++F7+kx0GHqa7aFt3JfRpR6AEeS42L6OIe7h1ldDCq3Vtny54FZCqjWqv4D39TK3z+XkwE7s0SQB8E7k5QiZ9xCrCPwS4mVeXijDD0rG2m1IvV6g9gDIUSbLBLkWLD+JG9DClfyLXGfZ0cWxlidOcv53qQn5er6kEKB2GFtu1Xqm42Y6I89Kw4NWRK6UI4USqPMgt9BcUdPkhi9OPVvJVrsVT7J2CYEpwcpKI3sy+PDOfNOkMBH/NMpaU+ajKW5q+sVK8T9Pwf6NjoBi5vpWx7Q8Oaxqo76P/zO9461uGqbd9lO+uVprsFeuv0w5OQq76j/Nf98F2D1oIVHo1yyoZY0Xf3Es925njy1oVSj19ka31Ig2Lq3Ipe7ulxiyN8PF6f9SDHUAnNEUSN70fvbbcgY8NV+l16+b/JDaqgWpURudf+CRC6fuCvTPrIjtjNBukVBMjtvdrC29bEeGLQ9/gxKmtCfhWqa9ylNZ5IzmbNhIZ38eFfJSm3HRmLTiLWKw8gmMEGH+hvF8wedGfOVdq10Danfu/cfH4/uxNoCNJD3b5LAhN/KNRbd0JadQMyeF+J+gl4ECjli4/hlC9ed9JaLb3MUkRcVgf2+yMge7r3otAkPNhPqV6+DK8MRlDq+vGBXac6DpBIr/xZJaferC+TdDvX8MAcvX98mFuArrhP7eaL/xbMXb08/wWAcmYOz3+gww2lRGl8G8MmBWvqKt3vxGwMgrziAqBqcMuNW0Mowwb8TXJGH0onEJ3ad//G7Vzb065ue3/6qXsxy44wvIFjtXuOtdbQ5FD1cfOax2m+l1EiBWTOsfPgV1RSZ8jp+dIubzGwBQOPLIVZhXbFWHKSXdcAAR5XGbJfo/a3nx8tsJaIn2gDX6Of0gwHipW5PeXmLvopSNcl8CSoyQeaYE8iftvhSl5rA+dWzsowyfjDTVQ97TkOD72tMHAbBZWG+guqExOm92OrVGtm0bhWsFPZ+DO7GtZbuZZMJU5VndP14pKZfdnzKQWkoBtNnFHcFETbdVvQHBJEOUdND+q+4gwGpWZ/PR4P3s2Kt5auTaC75jBMnQ7N/AA==

Binto86 commented 1 year ago
func main(){
while(x < s)
func something();
Binto86 commented 1 year ago
func foo(): System = 5;
Binto86 commented 1 year ago
func main(){
    foo
}

func foo() {}
Binto86 commented 1 year ago

public import Foo

Binto86 commented 1 year ago
import System.Collections.Immutable;
func main(){
    ImmutableArray<int32>.Empt|
}
Binto86 commented 1 year ago
label:
Kuinox commented 6 months ago
import System.Console;

func main() {
    while(return){}
}
System.NullReferenceException: Object reference not set to an instance of an object.
   at Draco.Compiler.Internal.OptimizingIr.FunctionBodyCodegen.BoxIfNeeded(TypeSymbol targetType, IOperand source)
   at Draco.Compiler.Internal.OptimizingIr.FunctionBodyCodegen.<VisitCallExpression>b__28_0(ValueTuple`2 pair)
   [truncated]

https://playground.draco-lang.org/#AsvMLcgvKlEIriwuSc3Vc87PK87PSbXm4korzUtWyE3MzNPQVKjmUgCC8ozMnFSNotSS0qI8zeparlouAA==

Kuinox commented 6 months ago

Likely the same issue: https://playground.draco-lang.org/#AsvMLcgvKlEIriwuSc3Vc87PK87PSbXm4korzUtWyE3MzNPQVKjmUgCCssQihQoFW4Wi1JLSojxrrlouAA==

Kuinox commented 6 months ago

https://playground.draco-lang.org/#AsvMLcgvKlEIriwuSc3Vc87PK87PSbXm4korzUtWyE3MzNPQVKjmyklMSs2x4lIAgrLEIoUKBVuF9PySfAWwuDVXLRcA

func main() {
label:
    var x = goto label;
}
System.NotImplementedException: The method or operation is not implemented.
   at Draco.Compiler.Internal.Codegen.MetadataCodegen.EncodeSignatureType(SignatureTypeEncoder encoder, TypeSymbol type)
   [truncated]