Wiki

Ticket #220 (closed defect: fixed)

Opened 14 years ago

Last modified 12 years ago

Using a . like a string concatentor causes COBRA INTERNAL ERROR.

Reported by: nevdelap Owned by: Chuck
Priority: minor Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

Not that I think . is or should be a string concatenator - my fingers have just been doing too much damn php. :P

class P
    def main
        print "a" . "b"

error: COBRA INTERNAL ERROR / InvalidCastException? / Cannot cast from source type to destination type.

(I assume CIEs are always bad and worthy of tickets.)

Change History

Changed 14 years ago by hopscc

Hmm I get a CIE/RequireException but it barfs all the same.
heres some lines of patch that trap that situation and throw a nicer message

Index: CobraParser.cobra
===================================================================
--- CobraParser.cobra	(revision 2409)
+++ CobraParser.cobra	(working copy)
@@ -2782,6 +2782,9 @@
 						right = .expression(prec)
 					if op == 'ASSIGN' and left inherits IdentifierExpr and (left to IdentifierExpr).name.startsWithNonLowerLetter
 						.recordError(ErrorMessages.localVariablesMustStartLowercase)			
+					if op == 'DOT' 
+						if  left inherits StringLit  or right inherits StringLit
+							.throwError('Use plus "+", not dot ".", for string concatenation')
 					left = BinaryOpExpr.make(opToken to !, op to !, left to !, right)
 			finally
 				.opStack.pop

Changed 14 years ago by hopscc

Is this a common enough eror to require a full blown patch (patch+relnote+new test)

Changed 14 years ago by Chuck

  • status changed from new to assigned
  • owner set to Chuck

Yes, we'll improve this. But I'll probably cut another 2010-09-XX release, apply your patch for 226 which hits the parser and then do this.

Changed 12 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.