Nil constructor silently breaks things
Not really an error, more a pitfall: Using a Nil constructor (e.g., for a language which uses
nil
instead ofnull
) triggers seemingly inconsistent behavior within Stratego.
(e.g., Nil() doesn’t match Nil() …)May be nice to have the SDF and/or Stratego editor and/or the compiler warn about usage of a Nil constructor.
(Although Nil might occasionally have a real use in Stratego code as the last node in a list?)
Submitted by Tobi Vollebregt on 11 October 2011 at 11:13
Issue Log
Interesting. Apparently this problem also exists with the C version:
echo ‘Nil’ | str ‘io-wrap(debug; ?Nil())’fails.
I suppose a warning in the SDF editor about this would be the best fix here. Since the term library is typed, it can’t just make an empty list term when you say it has to make something with constructor “Nil”.
added warning in r23444
I figured the parsing etc. is fine, what happens is that ?Nil() in Stratego is equivalent to ?[], and !Nil() is equivalent to ![]. Matching/building Nil can only be done using generic term construction/destruction.
Log in to post comments