Commit Graph

27 Commits

Author SHA1 Message Date
Daniel Duan
780b58a9a5 [Parser] update tests for 'inout' syntax adjustment 2016-02-26 01:33:22 -08:00
Daniel Duan
6498c163eb [Parser][SR-698][Qol] add diagnostic for trailing ',' in lists
https://bugs.swift.org/browse/SR-698
2016-02-10 19:18:59 -08:00
Chris Lattner
94dd92fcb8 Fix compiler_crashers 22725 & 28236 by reworking parameter parsing error
recovery a bit.
2016-02-01 20:50:32 -08:00
Doug Gregor
c9c1d1390c [SE-0021] Allow naming of specific initializers via "self.init(foo:bar:)". 2016-01-20 17:09:02 -08:00
Chris Lattner
4db5b98535 fix SR-573 - Crash with invalid parameter declaration
This makes sure to diagnose the error of not having a type on a parameter
in the parser, which is what sema expects.
2016-01-18 09:03:58 -08:00
Chris Lattner
7daaa22d93 Completely reimplement/redesign the AST representation of parameters.
Parameters (to methods, initializers, accessors, subscripts, etc) have always been represented
as Pattern's (of a particular sort), stemming from an early design direction that was abandoned.
Being built on top of patterns leads to patterns being overly complicated (e.g. tuple patterns
have to have varargs and default parameters) and make working on parameter lists complicated
and error prone.  This might have been ok in 2015, but there is no way we can live like this in
2016.

Instead of using Patterns, carve out a new ParameterList and Parameter type to represent all the
parameter specific stuff.  This simplifies many things and allows a lot of simplifications.
Unfortunately, I wasn't able to do this very incrementally, so this is a huge patch.  The good
news is that it erases a ton of code, and the technical debt that went with it.  Ignoring test
suite changes, we have:
   77 files changed, 2359 insertions(+), 3221 deletions(-)

This patch also makes a bunch of wierd things dead, but I'll sweep those out in follow-on
patches.

Fixes <rdar://problem/22846558> No code completions in Foo( when Foo has error type
Fixes <rdar://problem/24026538> Slight regression in generated header, which I filed to go with 3a23d75.

Fixes an overloading bug involving default arguments and curried functions (see the diff to
Constraints/diagnostics.swift, which we now correctly accept).

Fixes cases where problems with parameters would get emitted multiple times, e.g. in the
test/Parse/subscripting.swift testcase.

The source range for ParamDecl now includes its type, which permutes some of the IDE / SourceModel tests
(for the better, I think).

Eliminates the bogus "type annotation missing in pattern" error message when a type isn't
specified for a parameter (see test/decl/func/functions.swift).

This now consistently parenthesizes argument lists in function types, which leads to many diffs in the
SILGen tests among others.

This does break the "sibling indentation" test in SourceKit/CodeFormat/indent-sibling.swift, and
I haven't been able to figure it out.  Given that this is experimental functionality anyway,
I'm just XFAILing the test for now.  i'll look at it separately from this mongo diff.
2015-12-31 19:24:46 -08:00
Xi Ge
9ed7a57865 [Parser] When parsing error occurs on arguments, we still try to preserve the call expression.
This allows tools, like code completion or jumping to definition, to be able to resolve
function names even though the argument is wrong.

Swift SVN r31387
2015-08-21 19:41:11 +00:00
Chris Lattner
4b96cba12b Fix <rdar://problem/22143680> QoI: terrible diagnostic when trying to form a generic protocol
Swift SVN r31108
2015-08-10 16:50:45 +00:00
Chris Lattner
ada5487153 add fixit tests to random other tests.
Swift SVN r31006
2015-08-04 20:35:36 +00:00
Chris Lattner
3ad108b0be Reapply r29419:
Enhance fixItRemove() to be a bit more careful about what whitespace it leaves around: if the thing it is removing has leading and trailing whitespace already, this nukes an extra space to avoid leaving double spaces or incorrectly indented results.  

This includes an extra fix for looking off the start of a buffer, which extractText doesn't and can't handle.

This fixes <rdar://problem/21045509> Fixit deletes 'let' from non-binding 'if case let' statements, but leaves an extra space




Swift SVN r29449
2015-06-17 16:31:26 +00:00
Ted Kremenek
d13549e607 Revert "enhance fixItRemove() to be a bit more careful about what whitespace it leaves around:"
This was breaking the bots.

Swift SVN r29432
2015-06-17 02:20:52 +00:00
Chris Lattner
6b3167ab36 enhance fixItRemove() to be a bit more careful about what whitespace it leaves around:
if the thing it is removing has leading and trailing whitespace already, this nukes
an extra space to avoid leaving double spaces or incorrectly indented results.  This
fixes <rdar://problem/21045509> Fixit deletes 'let' from non-binding 'if case let' statements, but leaves an extra space



Swift SVN r29419
2015-06-17 00:55:59 +00:00
Chris Lattner
90a830f5fb Check in two testcases that were improved by r29222 that I somehow failed to commit
Swift SVN r29224
2015-06-02 04:51:39 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Chris Lattner
7059871abf Convert some 'var' bindings to 'let' when they are not mutated, some
var/let bindings to _ when they are never used, and use some values that
are only written.  This is a testsuite cleanup, NFC. More to come.


Swift SVN r28406
2015-05-11 00:20:55 +00:00
Argyrios Kyrtzidis
a935e7c13e [Lexer] Recognize editor placeholders as identifiers and provide a specific error when encountered.
Swift SVN r26212
2015-03-17 01:52:59 +00:00
Jordan Rose
fac5a83bbf Allow capturing super in explicit closures and nested functions.
The previous commit enabled this; now it's just about removing the
restriction in the parser and tightening up code completion.

Using 'super' in a closure where 'self' is captured weak or unowned still
doesn't work; the reference to 'self' within the closure is treated as
strong regardless of how it's declared. Fixing this requires a cascade of
effort, so instead I just cloned rdar://problem/19755221.

rdar://problem/14883824

Swift SVN r25065
2015-02-07 03:56:11 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Denis Vnukov
3c4c4f1483 Fix for rdar://problem/18926814 (Fuzzing swift: Swift parser crash).
The issue is reproducible in erroneous code scenario when a string literal
has invalid stuff inside interpolation segment, like: “... \( abc } ) ...”.

In this case we used to do some magic for switching context inside the string 
and parse the interior of \(...) as regular expression list, but expected that 
the parsing finishes at closing “)” which does not necessarily true in case
the code has errors.

The assertion was replaced with an error diagnostics.



Swift SVN r23296
2014-11-13 00:22:23 +00:00
Chris Willmore
cbcfa97814 Don't allow bare generic type syntax "<T1>T2" in Swift, only SIL.
rdar://problem/18507467

Swift SVN r22922
2014-10-24 21:24:02 +00:00
Chris Lattner
a2beb62f85 fix <rdar://problem/16786168> Functions currently permit 'var inout' parameters
fix <rdar://problem/17867059> ` upgrade logic should be removed




Swift SVN r20817
2014-07-31 06:18:42 +00:00
Dmitri Hrybenko
8234c70f88 Code completion: fix delayed parsing of closures
The delayed parsing was in place, but the expressions were being thrown away by
"recovery" in the parser.

rdar://16274593


Swift SVN r20151
2014-07-18 11:43:38 +00:00
Argyrios Kyrtzidis
24bbc2d0a5 [Parser] Fix infinite loop when there is a syntax error inside an uncovered statement in a switch.
rdar://17303380

Swift SVN r19031
2014-06-20 04:37:15 +00:00
Argyrios Kyrtzidis
7f1f1a459b [Parser] Fix crash when having "super.init()" at top-level.
rdar://16981275

Swift SVN r18532
2014-05-21 23:26:31 +00:00
Doug Gregor
c41f0e01ce Make # a real punctuator.
Swift SVN r17980
2014-05-13 00:03:01 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Argyrios Kyrtzidis
f875f05a30 [Lexer] When encountering invalid characters, emit diagnostic and ignore them.
...instead of returning tok::unknown, which may confuse the Parser and cause it to crash with llvm::unreachable.
By ignoring them we reduce the complexity in the Parser by not having it worry about tok::unknown.

Swift SVN r6910
2013-08-05 18:29:14 +00:00