Wiki

Ticket #221: methodcall-spaces.patch

File methodcall-spaces.patch, 1.5 KB (added by hopscc, 12 years ago)
  • Source/CobraParser.cobra

     
    28482848                # requires special handling - PostCallExpr 
    28492849                # this happens for something like: foo[i]('x') 
    28502850                if not PostCallExpr.isTargetAcceptable(left to !) 
    2851                     .throwError('Unexpected call.')  # example: t = x to List<of String>() 
     2851                    msg = '' 
     2852                    if left inherits DotExpr  
     2853                        if left.right inherits MemberExpr  # example: .somecall (arg) 
     2854                            msg =' Method calls should not have whitespace between the methodname and the parenthesised arglist.' 
     2855                    .throwError('Unexpected call.[msg]')  # example: t = x to List<of String>() 
    28522856                token = .grab 
    28532857                exprs = .commaSepExprs('RPAREN.') 
    28542858                return .expression(precedence, PostCallExpr(token, left, exprs)) 
  • Tests/820-errors/100-lexing-and-parsing/320-extra-spaces-methodcall.cobra

     
     1class Program 
     2 
     3    def main 
     4        a = .someCall ("abc") and _ # .error. should not have whitespace 
     5            .anotherCall("def")  
     6        print a 
     7 
     8    def someCall(s as String) as bool 
     9        return true 
     10 
     11    def anotherCall(s as String) as bool 
     12        return true 
     13