Page 1 of 1

Spurious warning on compiler compile

PostPosted: Tue Jul 08, 2008 4:00 am
by hopscc
While I'm nitpicking there a couple of warnings coming from the cobra compiler source when it compiles.
These are really annoying when scanning for errors from additions
It'd be nice if they werent there :o

CobraParser.cobra(1090): warning: The value of variable "attribs" is never used.

this is true ( presumably for the moment).
if these are placeholders for something in the future could we comment them out until the future something comes along and put a trailing note on them
if not can we remove (both) lines entirely?

The second is spurious
Boxes.cobra(853): warning: The expression "_needs_typeArgs" (of type "List<of IType>") will always evaluate to true because it is not nilable. You can remove the expression or check for non-empty collections with ".count".


The surrounding lines look like this
Code: Select all
   var _needs_typeArgs as List<of IType>?
      """
      When non-nil, this box is constructed from a generic *and* requires completion of its construction of members.
      """

   def completeMemberConstructionIfNeeded
      if _needs_typeArgs
         assert not .isGenericDef
         if not .didBindInt and not .isBindingInt
            .bindInt  # this is required when inheriting from a constructed type such as "class Foo inherits List<of int>". Since "bind inheritance" happens prior to "bind interface", the base type will have been partially constructed without ever binding int.
         if _needs_typeArgs
            _completeConstruction(_needs_typeArgs)
         _needs_typeArgs = nil

Line 853 is the second 'if _needs_typeArgs' statement. (whoa!)
This warning is spurious since _needs_typeArgs is clearly marked as nilable (List<of IType>?) AND its not complaining about the first
if _needs_typeArgs line (exactly the same).

Re: Spurious warning on compiler compile

PostPosted: Wed Sep 03, 2008 12:15 pm
by Charles
I fixed the warning about "attribs" by making use of the attribs. changeset:1608

Re: the warning about "will always evaluate to true", see ticket:41.

I then added a # .no-warnings. directive on that line but it's not working. If I misspell it, I get an error so the compiler is definitely checking for directives. If I spell it correctly, no error, but no suppression either. I get the same result with "make-trial; comp-trial" so I think there is a bug in the warning suppression code.

Re: Spurious warning on compiler compile

PostPosted: Wed Sep 03, 2008 11:11 pm
by hopscc
Its cos the noWarnings list is being replaced for each file (overwritten). If the warning is being generated from a stage after the
file is parsed the warning suppression record is no longer in existance....

fix is to augment the compiler._noWarningsList rather than overwriting it...
patch coming up - I'll attach it to ticket:41

Re: Spurious warning on compiler compile

PostPosted: Sat Sep 13, 2008 11:38 pm
by Charles
Fixed in development. I didn't use the patch which contained no test cases. Also, I thought it was more clear to call .addRange() directly than have a property setter do it. changeset:1620