Thread overview
problem while updating to 2.052
Feb 19, 2011
Christian Köstlin
Feb 19, 2011
bearophile
Feb 19, 2011
Christian Köstlin
Feb 21, 2011
novice2
Feb 21, 2011
Jonathan M Davis
Feb 21, 2011
novice2
February 19, 2011
hi .. i have a small library for combinatorial parsing.
when i updated to version 2.052 of dmd (tested on os x) i got an exception from variant.d:279 (target must be non-null).
i fixed the problem with the following diff:
     ParseResult!(T) parse(T[] s) {
-      auto results = appender!(Variant[])();
+      Variant[] results;
       auto rest = s;
       while (true) {
         auto res = fToRepeat.parse(rest);
         if (res.success) {
           rest = res.rest;
-          results.put(res.results);
+          results = results ~ res.results;
         } else {
           break;
         }
       }
-      return transform(ParseResult!(T).ok(rest, results.data));
+      return transform(ParseResult!(T).ok(rest, results));
     }

what did i do wrong and why could it work with an older version of dmd2?

thanks in advance

christian koestlin
February 19, 2011
Christian K.:

> hi .. i have a small library for combinatorial parsing.
> when i updated to version 2.052 of dmd (tested on os x) i got an
> exception from variant.d:279 (target must be non-null).

It may be a bug. Are you able to create a minimal test program that later will be fit for bugzilla?

Bye,
bearophile
February 19, 2011
On 2/19/11 22:06 , bearophile wrote:
> Christian K.:
>
>> hi .. i have a small library for combinatorial parsing.
>> when i updated to version 2.052 of dmd (tested on os x) i got an
>> exception from variant.d:279 (target must be non-null).
>
> It may be a bug. Are you able to create a minimal test program that later will be fit for bugzilla?
>
> Bye,
> bearophile
Hi,

unfortunately not ... I looked several minutes at the stacktrace (would it help if I send you the whole project), and could not figure out what the problem was. then I tried to change the program (see the diff) and it worked.

this is the stacktrace of the exception if it helps:
core.exception.AssertError@/Users/gizmo/.homebrew/Cellar/dmdtwo/2.052/src/phobos/std/variant.d(279): target must be non-null
----------------
5   compiler                            0x000340b5 onAssertErrorMsg + 73
6   compiler                            0x0003dfb2 _d_assert_msg + 26
7   compiler                            0x0000ea76 int std.variant.VariantN!(32).VariantN.handler!(astelements.MessageInfo).handler(std.variant.VariantN!(32).VariantN.OpID, ubyte[32]*, void*).bool tryPutting(astelements.MessageInfo*, TypeInfo, void*) + 130
8   compiler                            0x0000e75c int std.variant.VariantN!(32).VariantN.handler!(astelements.MessageInfo).handler(std.variant.VariantN!(32).VariantN.OpID, ubyte[32]*, void*) + 200
9   compiler                            0x000152a2 std.variant.VariantN!(32).VariantN std.variant.VariantN!(32).VariantN.opAssign!(std.variant.VariantN!(32).VariantN).opAssign(std.variant.VariantN!(32).VariantN) + 78
10  compiler                            0x0001613a void std.array.Appender!(std.variant.VariantN!(32).VariantN[]).Appender.put!(std.variant.VariantN!(32).VariantN).put(std.variant.VariantN!(32).VariantN) + 134
11  compiler                            0x000161cb void std.array.Appender!(std.variant.VariantN!(32).VariantN[]).Appender.put!(std.variant.VariantN!(32).VariantN[]).put(std.variant.VariantN!(32).VariantN[]) + 115
12  compiler                            0x0000aa8a pc.parser.ParseResult!(immutable(char)).ParseResult pc.parser.Parser!(immutable(char)).Parser.Repetition.parse(immutable(char)[]) + 422
13  compiler                            0x0000a369 pc.parser.ParseResult!(immutable(char)).ParseResult pc.parser.Parser!(immutable(char)).Parser.parseAll(immutable(char)[]) + 41
14  compiler                            0x000026b6 _Dmain + 446
15  compiler                            0x0003e343 extern (C) int rt.dmain2.main(int, char**).void runMain() + 23
16  compiler                            0x0003e2ca extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 38
17  compiler                            0x0003e38b extern (C) int rt.dmain2.main(int, char**).void runAll() + 59
18  compiler                            0x0003e2ca extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 38
19  compiler                            0x0003e25b main + 179
20  compiler                            0x000024ed start + 53
21  ???                                 0x00000003 0x0 + 3

regarding types:
my debugoutput at the exception showed me, that the appender already has one element of type astelements.PackageInfo and now an array with one element of type astelements.MessageInfo is to be put into the appender. perhaps this can lead to a problem?
messageinfo is a struct declared like:
struct MessageInfo {
  string name;
  FieldInfo[] fieldInfos;
  EnumDefinition[] enums;
  MessageInfo[] messages;
  string thePackage = "";
 ...
}
, packageinfo is even simpler:

class PackageInfo {
  string fName;
  this(string name) {
    fName = name;
  }
}


thanks in advance

christian
February 21, 2011
Christian Köstlin Wrote:

> unfortunately not ... I looked several minutes at the stacktrace (would

i am sorry for offtopic, but
how you produce stacktrace? sometime i very want to see it...
February 21, 2011
On Sunday 20 February 2011 22:11:13 novice2 wrote:
> Christian Köstlin Wrote:
> > unfortunately not ... I looked several minutes at the stacktrace (would
> 
> i am sorry for offtopic, but
> how you produce stacktrace? sometime i very want to see it...

1. It doesn't work on Windows yet, I don't believe. So, for now, you're out of luck. I don't know about Mac OS X.

2. On Linux, any Throwable (be it an Exception or an Error) which escapes main will print a stack trace.  IIRC, you also get a stack trace when you convert an Exception to a string. Regardless, you need to have linked with -L--export- dynamic to get the function names to work, but that's in the dmd.conf, so you should always be building with it.

- Jonathan M Davis
February 21, 2011
Jonathan M Davis, thank you for explanation,
but i am on windows :(