Ticket #165: ticket165.patch
File ticket165.patch, 1.9 KB (added by eric.sellon, 15 years ago) |
---|
-
Source/Statements.cobra
509 509 _step.bindImp 510 510 else if _step inherits IntegerLit 511 511 _dir = if(_step.value < 0, -1, +1) 512 if _checkCompatibleTypes(_start.type to !, _stop.type to !) 513 if _step 514 if not _checkCompatibleTypes(_start.type to !, _step.type to !) 515 .throwError('For loop start condition type [_start.type.name] is not compatible with step condition type [_step.type.name].') 516 else if not _checkCompatibleTypes(_stop.type to !, _step.type to !) 517 .throwError('For loop stop condition type [_stop.type.name] is not compatible with step condition type [_step.type.name].') 518 else 519 .throwError('For loop start condition type [_start.type.name] is not compatible with stop condition type [_stop.type.name].') 512 520 513 521 def inferredType as IType? is override 514 522 return _start.type.greatestCommonDenominatorWith(_stop.type to !) 523 524 def _checkCompatibleTypes(type1 as IType, type2 as IType) as bool 525 if type1.isDynamic or type2.isDynamic 526 return true 527 else if type1 == type2 528 return true 529 else if type1.isDescendantOf(.compiler.anyIntType) and type2.isDescendantOf(.compiler.anyIntType) 530 return true 531 else 532 return false 515 533 516 534 517 535 class ForEnumerableStmt -
Tests/110-basics-two/910-bad-numeric-loop-message.cobra
1 class X 2 def main 3 j = 4 4 for i in 0 : j/2 # .error. The for loop 5 pass 6 for i in 2 : 10 : 1.5 # .error. The for loop 7 pass 8 for i in 1 : 11.5 : 0.5 # .error. The for loop 9 pass 10 k = 3 to dynamic 11 for i in k : 12 : 1.5 # .error. The for loop 12 pass 13 No newline at end of file