Ticket #199: inout-mismatch.patch
File inout-mismatch.patch, 3.4 KB (added by hopscc, 15 years ago) |
---|
-
Source/Expr.cobra
744 744 break 745 745 assert arg.didBindImp 746 746 assert param.didBindInt 747 # chk any IN/OUT/INOUT settings are synchronised 748 if not param.matchLabel(arg.argumentLabel) 749 arg.recordError('Argument [i+1] of method "[_name]" expects a parameter labelled as ([param.kind]), but the call is supplying a label of ([arg.argumentLabel]).') 747 750 if arg.canBeAssignedTo(param.type) 748 751 arg.contextType = param.type 749 752 else if param.type inherits GenericParam … … 766 769 arg.recordError('Argument [i+1] of method "[_name]" expects a non-nilable type ([param.type.name]), but the call is supplying a nilable type ([arg.type.name]).') 767 770 else 768 771 arg.recordError('Argument [i+1] of method "[_name]" expects type [param.type.name], but the call is supplying type [arg.type.name].') 769 772 770 773 def toCobraSource as String is override 771 774 sb = StringBuilder() 772 775 sb.append(_name) -
Source/Vars.cobra
215 215 attrib.bindImp 216 216 catch ne as NodeException 217 217 .compiler.recordError(ne) 218 219 218 219 def matchLabel(label as ArgumentLabel) as bool 220 """ Verify argumentLabel from method argument matches parameter kind """ 221 isValid = false 222 branch label 223 on ArgumentLabel.None 224 isValid = .kind == .KindEnum.Value 225 on ArgumentLabel.Out 226 isValid = .kind == .KindEnum.Out 227 on ArgumentLabel.InOut 228 isValid = .kind == .KindEnum.InOut 229 return isValid 230 220 231 class LocalVar inherits AbstractLocalVar is partial 221 232 222 233 cue init(token as IToken, type as IType) -
Tests/120-classes/955-inout-mismatch.cobra
1 # Test cobra catches mismatch on (in)/out/inout labels between args and params 2 class InOutMismatch 3 4 def foo(x as inout int) 5 x = 5 6 7 def bar(x as out int) 8 x = 15 9 10 def baz(x as int) 11 pass 12 13 def main 14 y = 0 15 .foo(y) # .error. supplying a label of (None). 16 assert y == 5 17 .foo(out y) # .error. supplying a label of (Out). 18 assert y == 5 19 .foo(inout y) # OK 20 assert y == 5 21 22 z = 0 23 .bar(z) # .error. supplying a label of (None). 24 assert z == 15 25 .bar(inout z) # .error. supplying a label of (InOut). 26 assert z == 15 27 .bar(out z) # OK 28 assert z == 15 29 30 x = 0 31 .baz(x) # OK 32 assert x == 0 33 .baz(out x) # .error. supplying a label of (Out). 34 assert x == 0 35 .baz(inout x) # .error. supplying a label of (InOut). 36 assert x == 0 37 -
Developer/IntermediateReleaseNotes.text
451 451 * Fixed: References to local variables in `ensure` are not flagged as errors. ticket:198 452 452 453 453 * Fixed: Cannot directly refer to an open generic type such as `t = List<of>`. ticket:192 454 455 * Fixed: Missing inout gets C# error message rather thn cobra error message. ticket:199