nitra
nitra copied to clipboard
Erroneous syntax definition causes KeyNotFoundException
The following syntax definition produces a KeyNotFoundException
during parsing:
namespace Test
{
using Nitra.Core;
syntax module TestSyntax
{
syntax Foo = Bar '+ Bar; // Note: The single quote is missing after the plus sign
regex Bar = "Bar";
}
}
The expected behaviour would be to get some parse errors instead.
Can not reproduce.
I've originally been running this in the old visualizer, which didn't give me more information than the exception message. With the new visualizer I got the stacktrace from below. Also I got proper syntax highlighting and error messages
Based on that info it looks like the issue title isn't quiet correct. It's definitely not the parsing phase.
Pasting the code into the new visualizer should be sufficient to produce a message box continaing the exception text and stacktrace. However, my local repo currently isn't up to date with master
. If you still can't reproduce it, I can try to get the latest version and see if it still happens there.
Project loading is failed in call RefreshProject().
Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Nitra.Ast.RuleFieldNameGenerator.GetName(Location loc, ParsedValue`1 desiredName) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\Members\RuleFieldNameGenerator.n:Line 66.
at Nitra.Ast.RuleField.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\Members\RuleField.nitra:Line 27.
at Nitra.Ast.RuleField.AstList.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\Members\RuleField.nitra:Line 0.
at Nitra.Internal.AstUtils.EvalAmbiguitiesProperties(DependentPropertyEvalContext context, IAmbiguousAst ast) in D:\<...>\Nitra\Nitra\Nitra.Runtime\Declarations\AstUtils.n:Line 32.
at Nitra.Declarations.AmbiguousAstList`1.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\Nitra.Runtime\Declarations\AstList.n:Line 135.
at Nitra.Ast.TopSimpleRule.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\Members\SyntaxModuleMember\TopRule.nitra:Line 0.
at Nitra.Ast.SyntaxModuleMember.AstList.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\Members\SyntaxModuleMember\SyntaxModuleMember.nitra:Line 0.
at Nitra.Ast.SyntaxModule.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\SyntaxModule.nitra:Line 33.
at DotNet.NamespaceMember.AstList.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\DotNetLang\Namespace\NamespaceMember.nitra:Line 0.
at DotNet.ExplicitNamespace.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\DotNetLang\Namespace\Namespace.nitra:Line 49.
at DotNet.NamespaceMember.AstList.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\DotNetLang\Namespace\NamespaceMember.nitra:Line 0.
at DotNet.CompilationUnit.EvalProperties(DependentPropertyEvalContext context) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\DotNet\CompilationUnit.nitra:Line 10.
at Nitra.Declarations.EvalPropertiesHost.EvalProperties(DependentPropertyEvalContext context, IDependentPropertyContainer obj, Single statistics) in D:\<...>\Nitra\Nitra\Nitra.Runtime\DependentProperties\EvalPropertiesHost.n:Line 66.
at Nitra.Declarations.ProjectEvalPropertiesHost.ExecutePass(DependentPropertyEvalContext context, String passName) in D:\<...>\Nitra\Nitra\Nitra.Runtime\DependentProperties\ProjectEvalPropertiesHost.n:Line 47.
at Nitra.Declarations.EvalPropertiesHost.EvalProperties(DependentPropertyEvalContext context, String passName, Int32 stage) in D:\<...>\Nitra\Nitra\Nitra.Runtime\DependentProperties\EvalPropertiesHost.n:Line 41.
at DotNet.CompilationUnit.RefreshProject(CancellationToken cancellationToken, ImmutableArray`1 files, Object data) in D:\<...>\Nitra\Nitra\Nitra.Grammar\AST\DotNet\CompilationUnit.n:Line 103.
at Nitra.ClientServer.Server.ParseWorker.ProcessMessage(ParserMessage msg) in D:\<...>\Nitra\Nitra\ClientServer\Nitra.ClientServer.Server\ParseWorker.n:Line 167.