Ticket #265 (closed defect: fixed)
Combined enum bitset test missing == value causes compiler Exception
Reported by: | hopscc | Owned by: | Chuck |
---|---|---|---|
Priority: | medium | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | Cc: |
Description
This program
class EnumComb enum States has Flags Init=1, Settling=2, Pour=4 def main is shared x = States.Init y = States(Init, Settling) #assert (x & y) == x if x & y print 'x non0 in y -bitwise'
causes this error
Unhandled Exception: Cobra.Lang_ert_04ffb25fa124e79edfd9952341f0b305.FallThroughException: info=TruthExpr-sh(14586, didBindInh=false, didBindInt=false, didStartBindImp=true, isBindingImp=true, didBindImp=false, token=Token(AMPERSAND, '&', '&', ln 10, col 8, EnumCombineTestBug.cobra), Treatment=AsIs, type=nil, 14586) at TruthExpr._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\Expr.cobra:line 2195 at Node.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Node.cobra:line 560 at Stmt.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Statements.cobra:line 108 at Expr.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Expr.cobra:line 193 at IfStmt._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\Statements.cobra:line 680 at Node.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Node.cobra:line 560 at Stmt.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Statements.cobra:line 108 at AbstractMethod._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\Members.cobra:line 886 at Method._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\Members.cobra:line 1201 at Node.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Node.cobra:line 560 at BoxMember.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Members.cobra:line 256 at Box._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\Boxes.cobra:line 740 at ClassOrStruct._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\Boxes.cobra:line 1132 at Node.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Node.cobra:line 560 at NameSpace._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\NameSpace.cobra:line 233 at Node.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Node.cobra:line 560 at CobraModule._bindImp() in c:\home\hops\src\cobra\wkspace1\Source\Module.cobra:line 97 at Node.BindImp() in c:\home\hops\src\cobra\wkspace1\Source\Node.cobra:line 560 at BindImplementationPhase.InnerRun() in c:\home\hops\src\cobra\wkspace1\Source\Phases\phases\BindImplementationPhase.cobra:line 18 at Phase.Run() in c:\home\hops\src\cobra\wkspace1\Source\Phases\phases\Phase.cobra:line 102 at Compiler.RunPhase(Phase phase) in c:\home\hops\src\cobra\wkspace1\Source\Compiler.cobra:line 322 at Compiler._compileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Predicate`1 stopCompilation) in c:\home\hops\src\cobra\wkspace1\Source\Compiler.cobra:line 390 at Compiler.CompileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Predicate`1 stopCompilation) in c:\home\hops\src\cobra\wkspace1\Source\Compiler.cobra:line 344 at CommandLine.DoCompile(List`1 paths, Boolean willPrintSuccessMsg, Boolean writeTestInvocation, Predicate`1 stopCompilation) in c:\home\hops\src\cobra\wkspace1\Source\CommandLine.cobra:line 676 at CommandLine.DoRun(List`1 paths) in c:\home\hops\src\cobra\wkspace1\Source\CommandLine.cobra:line 790 at CommandLine.Run(List`1 args) in c:\home\hops\src\cobra\wkspace1\Source\CommandLine.cobra:line 637 at CommandLine.Run() in c:\home\hops\src\cobra\wkspace1\Source\CommandLine.cobra:line 575 at CobraMain.Main() in c:\home\hops\src\cobra\wkspace1\Source\cobra.cobra:line 17 (null) 624 xx:...hops/src/cobra/Tst>
which is corrected by this patch
Index: Expr.cobra =================================================================== --- Expr.cobra (revision 2461) +++ Expr.cobra (working copy) @@ -2192,7 +2192,7 @@ type = _expr.type if type is .compiler.boolType _treatment = Treatment.AsIs - else if type inherits AbstractNumberType + else if type inherits AbstractNumberType or type inherits EnumDecl _treatment = Treatment.CompareToZero else if _expr inherits NilLiteral .compiler.warning(this, 'The value nil will always evaluate to false.')
Change History
Note: See
TracTickets for help on using
tickets.