asn1scc crashes during parsing value assignment with SEQUENCE
rphh opened this issue · comments
I have the following definitions ASN.1:
MyInteger ::= INTEGER (0 .. 10000)
x MyInteger ::= 2
z INTEGER ::= 23
t SEQUENCE { a INTEGER (0..10), b INTEGER (0..10) } ::= { a 2, b 3 }
The asn1scc invocation ends with following error with stacktrace.
$ asn1scc test.asn
Index was outside the bounds of the array.
at CreateAsn1AstFromAntlrTree.CreateChild@403(BigInteger integerSizeInBytes, FSharpList`1 tasParameters, FSharpOption`1 seqAcnTypeEncodingSpec, FSharpList`1 astRoot, IToken[] fileTokens, List`1 alreadyTakenComments, ITree x) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 404
at CreateAsn1AstFromAntlrTree.asn1Children@451.Invoke(ITree x) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 451
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 250
at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 list) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 75
at CreateAsn1AstFromAntlrTree.CreateSequenceChild(BigInteger integerSizeInBytes, FSharpList`1 tasParameters, FSharpOption`1 seqAcnTypeEncodingSpec, FSharpList`1 astRoot, ITree tree, IToken[] fileTokens, List`1 alreadyTakenComments) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 451
at CreateAsn1AstFromAntlrTree.CreateType(BigInteger integerSizeInBytes, FSharpList`1 tasParameters, FSharpOption`1 acnTypeEncodingSpec, FSharpList`1 astRoot, ITree tree, IToken[] fileTokens, List`1 alreadyTakenComments) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 218
at CreateAsn1AstFromAntlrTree.CreateValueAssignment(BigInteger integerSizeInBytes, FSharpList`1 astRoot, ITree tree) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 680
at CreateAsn1AstFromAntlrTree.CreateAsn1Module@745-1.Invoke(ITree x) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 745
at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 241
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 251
at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 list) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 75
at CreateAsn1AstFromAntlrTree.CreateAsn1Module(BigInteger integerSizeInBytes, FSharpList`1 astRoot, AcnAst acnAst, FSharpList`1 implicitlyImportedTypes, ITree tree, IToken[] fileTokens, List`1 alreadyTakenComments) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 743
at CreateAsn1AstFromAntlrTree.CreateAsn1File@774.Invoke(ITree t) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 774
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 248
at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 list) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 75
at CreateAsn1AstFromAntlrTree.CreateAsn1File(BigInteger integerSizeInBytes, FSharpList`1 astRoot, AcnAst acnAst, FSharpList`1 implicitlyImportedTypes, ITree tree, String file, IToken[] tokens) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 772
at CreateAsn1AstFromAntlrTree.CreateAstRoot@846-1.Invoke(AntlrParserResult x) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 846
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 248
at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 list) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 75
at CreateAsn1AstFromAntlrTree.CreateAstRoot(FSharpList`1 list, AcnAst acnAst, CommandLineSettings args) in /home/taste/GitLocal/asn1scc/FrontEndAst/CreateAsn1AstFromAntlrTree.fs:line 845
at FrontEntMain.constructAst(CommandLineSettings args, FSharpFunc`2 debugFnc) in /home/taste/GitLocal/asn1scc/FrontEndAst/FrontEntMain.fs:line 58
at Program.main0(String[] argv) in /home/taste/GitLocal/asn1scc/asn1scc/Program.fs:line 284
It seems that assignments to both integers are accepted by asn1scc, the bug occurs when assignment to the SEQUENCE value is uncommented.
Thank's for reporting this issue.
You can easily overcome this issue by first declaring the type and then the value.
E.g.
Instead of
t SEQUENCE { a INTEGER (0..10), b INTEGER (0..10) } ::= { a 2, b 3 }
write this
T ::= SEQUENCE { a INTEGER (0..10), b INTEGER (0..10) }
t T ::= { a 2, b 3 }