FAQ

On 5 January 2015 at 16:58, nicolas riesch wrote:

Thank you very much for all your answers.
Sorry, there was a typo in my question, I was looking for '==' equality
operators, and not assignments.
Yes, I meant equality too; assignments was a typo.


The program also prints expressions of the kind a == nil (where a is of
type *foo.Bar)
It is correct, but I would like to filter them out.
I haven't found the proper method in ssa or types package that returns
whether an operand is the nil value.
Can you give me a pointer ?
nil is an *ssa.Const, and in fact it's the only possible ssa.Const since
this is a comparison of pointers.
So if you change the predicate to:

         if types.Identical(binop.X.Type(), A) && !isConst(binop.X) &&
!isConst(binop.Y) {

and add this utility:

         func isConst(x ssa.Value) bool {
                 _, ok := x.(*ssa.Const)
                 return !ok
         }

it should do what you want.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 8 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 4, '15 at 9:27p
activeJan 5, '15 at 10:28p
posts8
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase