The documentation can be interpreted as you say.

If the resulting AST is subsequently inserted into a larger AST and then 
serialized, the source that is output can be syntactically invalid.

It is unexpected (and I believe unreasonable) that serializing an AST can 
produce code that can't be parsed.

There is no API for invalidating the Pos information of an AST.  In order 
to make my application work, I needed to implement a function which copied 
an entire AST except for its Pos information 
(https://raw.githubusercontent.com/MarkNahabedian/Goshua/master/rete/rule_compiler/nopos.go).


Issue filed:
https://github.com/golang/go/issues/26986


On Tuesday, August 14, 2018 at 10:12:10 AM UTC-4, Marvin Renich wrote:
>
> * na...@mit.edu <javascript:> <na...@mit.edu <javascript:>> [180814 
> 09:47]: 
> > The documentation for parser.ParseExpr says that the position 
> information 
> > in the AST it returns "is undefined".  I opserved the result as having 
> > position information.  This looks like a bug. 
> > 
> > https://play.golang.org/p/tpzqDF3EZ_S 
> > 
> > demonstrates this bug. 
>
> Why would you say this is a bug?  The documentation explicitly says the 
> position information is "undefined".  Undefined means that you might get 
> a value, but the value will be nonsense.  The value might coincidentally 
> be relevant, but you cannot rely on it because you will not be able to 
> determine whether it is nonsense, coincidentally relevant and correct, 
> or coincidentally relevant and incorrect. 
>
> Obtaining a coincidentally relevant and correct value for something that 
> is defined to be "undefined" is not a bug; it just happens sometimes. 
>
> "Undefined" may also be used when the current code returns something 
> correct, but the authors wish to reserve the right (i.e. not break Go 1 
> Compatibility) to change the implementation in a way that does not give 
> a meaningful value. 
>
> ...Marvin 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to