diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 412d3f57890f4..529c0c9c361dd 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3912,7 +3912,7 @@ Parser::parseDecl(ParseDeclOptions Flags, const bool IsProbablyFuncDecl = Tok.isIdentifierOrUnderscore() || Tok.isAnyOperator(); - if (IsProbablyFuncDecl) { + if (IsProbablyFuncDecl && (!peekToken().is(tok::period))) { DescriptiveDeclKind DescriptiveKind; diff --git a/test/Parse/diagnostic_missing_func_keyword.swift b/test/Parse/diagnostic_missing_func_keyword.swift index 295f9d73eea4b..8d2bd0ebc1f2d 100644 --- a/test/Parse/diagnostic_missing_func_keyword.swift +++ b/test/Parse/diagnostic_missing_func_keyword.swift @@ -2,6 +2,25 @@ // https://bugs.swift.org/browse/SR-10477 +// RUN: %target-typecheck-verify-swift + +struct SR13098 { // expected-note {{in declaration of 'SR13098'}} + var srValue = 0xABABABAB // expected-note {{'srValue' previously declared here}} + var a: Int + + srValue = 0xCDCDCDCD // expected-error {{invalid redeclaration of 'srValue'}} + // expected-error @-1 {{expected 'var' keyword in property declaration}} + + + // ensure that the id.id pattern is not interpreted as a function + a.foo = 345 // expected-error {{expected declaration}} + + // note that the expected declaration blocks further diagnostics up to + // the closing right brace. + srValue.bar = 345 +} + + protocol Brew { // expected-note {{in declaration of 'Brew'}} tripel() -> Int // expected-error {{expected 'func' keyword in instance method declaration}} {{3-3=func }}