Wiki

Ticket #206 (closed defect: fixed)

Opened 14 years ago

Last modified 14 years ago

Unresolvable expression in dict literal in assignment causes compiler exception

Reported by: hopscc Owned by: Chuck
Priority: major Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

class EnumDictBug
	def main is shared
		keymap = { 
			ConsoleKey.Numpad0: 'kp0',  # typo
			#ConsoleKey.NumPad0: 'kp0',  # this is correct enum
			ConsoleKey.NumPad1: 'kp1'
		}
		assert keymap.count == 2

cause compiler exception and barf with

Unhandled Exception: Cobra.Lang_ert_44a69ed47c4bfcab1cc2ac6b01a36173.AssertException:
sourceSite = C:\home\hops\src\cobra\wkspace\Source\BinaryOpExpr.cobra:230 in AssignExpr._bindImp for object AssignExpr-sh(5460, didBindInh=false, didBindInt=false, didStartBindImp=true, isBindingImp=true, didBindImp=false, token=Token(ASSIGN, '=', '=', ln 3, col 10, EnumDictBug.cobra), type=nil, 5460)
info       = nil
this       = AssignExpr-sh(5460, didBindInh=false, didBindInt=false, didStartBindImp=true, isBindingImp=true, didBindImp=false, token=Token(ASSIGN, '=', '=', ln 3, col 10, EnumDictBug.cobra), type=nil, 5460)
    right.type = nil
        right = DictLit-sh(5459, didBindInh=false, didBindInt=false, didStartBindImp=true, didBindImp=true, token=Token(LCURLY, '{', '{', ln 3, col 12, EnumDictBug.cobra), type=nil, 5459)

   at AssignExpr._bindImp() in c:\home\hops\src\cobra\wkspace\Source\BinaryOpExpr.cobra:line 230
   at Node.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Node.cobra:line 562
   at Stmt.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Statements.cobra:line 108
   at Expr.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Expr.cobra:line 185
   at BinaryOpExpr.BindImp() in c:\home\hops\src\cobra\wkspace\Source\BinaryOpExpr.cobra:line 104
   at AbstractMethod._bindImp() in c:\home\hops\src\cobra\wkspace\Source\Members.cobra:line 886
   at Method._bindImp() in c:\home\hops\src\cobra\wkspace\Source\Members.cobra:line 1201
   at Node.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Node.cobra:line 562
   at BoxMember.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Members.cobra:line 256
   at Box._bindImp() in c:\home\hops\src\cobra\wkspace\Source\Boxes.cobra:line 743
   at ClassOrStruct._bindImp() in c:\home\hops\src\cobra\wkspace\Source\Boxes.cobra:line 1135
   at Node.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Node.cobra:line 562
   at NameSpace._bindImp() in c:\home\hops\src\cobra\wkspace\Source\NameSpace.cobra:line 233
   at Node.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Node.cobra:line 562
   at CobraModule._bindImp() in c:\home\hops\src\cobra\wkspace\Source\Module.cobra:line 97
   at Node.BindImp() in c:\home\hops\src\cobra\wkspace\Source\Node.cobra:line 562
   at BindImplementationPhase.InnerRun() in c:\home\hops\src\cobra\wkspace\Source\Phases\phases\BindImplementationPhase.cobra:line 18
   at Phase.Run() in c:\home\hops\src\cobra\wkspace\Source\Phases\phases\Phase.cobra:line 102
   at Compiler.RunPhase(Phase phase) in c:\home\hops\src\cobra\wkspace\Source\Compiler.cobra:line 322
   at Compiler._compileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Predicate`1 stopCompilation) in c:\home\hops\src\cobra\wkspace\Source\Compiler.cobra:line 386
   at Compiler.CompileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Predicate`1 stopCompilation) in c:\home\hops\src\cobra\wkspace\Source\Compiler.cobra:line 344
   at CommandLine.DoCompile(List`1 paths, Boolean willPrintSuccessMsg, Boolean writeTestInvocation, Predicate`1 stopCompilation) in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 676
   at CommandLine.DoRun(List`1 paths) in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 790
   at CommandLine.Run(List`1 args) in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 637
   at CommandLine.Run() in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 575
   at CobraMain.Main() in c:\home\hops\src\cobra\wkspace\Source\cobra.cobra:line 17
(null)

Change History

Changed 14 years ago by Chuck

  • owner set to Chuck
  • status changed from new to assigned
  • summary changed from Unresolvable Enum value in Dict literal causes compiler crash to Unresolvable expression in dict literal in assignment causes compiler exception

Enums aren't part of the source problem. Something as simple as this will trigger it:

d = {badname: 1}

Changed 14 years ago by Chuck

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in changeset:2399

Thanks for the report.

Note: See TracTickets for help on using tickets.