Commit Graph

203 Commits

Author SHA1 Message Date
Doug Gregor
ac93e35b01 Address Chris's review comments on @autoclosure(escaping).
Swift SVN r25251
2015-02-12 21:20:59 +00:00
Doug Gregor
954b4e4d83 Implement @autoclosure(escaping).
Addresses rdar://problem/19499207.

Swift SVN r25249
2015-02-12 21:09:47 +00:00
Denis Vnukov
0d84be65de Fix for rdar://problem/19605567, Fuzzing Swift: abort() in Verifier::checkSourceRanges(...)
Correct start/end locations of constructor arguments and class body in erroneous scenarios.



Swift SVN r24769
2015-01-28 01:05:36 +00:00
Denis Vnukov
196d500439 Fix for rdar://problem/19563867, Fuzzing Swift: Parser::parseTopLevel() crashes in Verifier::walkToPatternPost(swift::Pattern*):
a vararg subpattern of a TuplePattern should be a TypedPattern

Check for a vararg subpattern to be a typed pattern seemed to be missing in closure arguments parsing.



Swift SVN r24733
2015-01-26 21:11:32 +00:00
Doug Gregor
b642c555be Allow one to change the argument labels of curried function parameters.
Curried function parameters (i.e., those past the first written
parameter list) default to having argument labels (which they always
have), but any attempt to change or remove the argument labels would
fail. Use the fact that we keep both the argument labels and the
parameter names in patterns to generalize our handling of argument
labels to address this problem.

The IDE changes are due to some positive fallout from this change: we
were using the body parameters as labels in code completions for
subscript operations, which was annoying and wrong.

Fixes rdar://problem/17237268.

Swift SVN r24525
2015-01-19 22:15:14 +00:00
Chris Lattner
407bad1445 remove @autoclosure as a type attribute. Recognize it in a parameter
list and produce a nice fixit, so that people using it have an obvious
upgrade path.


Swift SVN r24075
2014-12-22 20:14:56 +00:00
Chris Lattner
86c3c50157 Implement support for parsing declattrs on parameters. The only tricky
case is where there is no argument name, because declattrs and typeattrs
can be juxtaposed.



Swift SVN r24045
2014-12-19 23:42:12 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Doug Gregor
51c1433ddd Add magic "literal" __DSO_HANDLE__ to refer to the DSO handle.
__DSO_HANDLE__ can be used as a callee-side default
argument. Addresses rdar://problem/17878114.


Swift SVN r21440
2014-08-25 16:33:54 +00:00
Chris Lattner
61715b1da7 Remove some dead code: pattern parsing is now never used for argument lists,
so inout can't appear there and we don't need to propagate an "isArgumentList"
bool down through pattern parsing.  NFC.



Swift SVN r20835
2014-07-31 17:46:08 +00:00
Chris Lattner
bc2071a66f make 'inout' be a keyword, to match var and let.
Swift SVN r20829
2014-07-31 16:36:56 +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
Doug Gregor
ff92b5f007 Remove -[no]implicit-objc-with.
Toggling this option causes funny things to happen, and there's no
point in keeping it.

Swift SVN r20565
2014-07-25 22:13:46 +00:00
Doug Gregor
795f568898 Start diagnosing the use of '`' rather than '#', with a Fix-It.
<rdar://problem/16891828>.

Swift SVN r17982
2014-05-13 00:03:05 +00:00
Doug Gregor
1efd9fba5b Start accepting '#' in addition to '`' to mark a keyword argument <rdar://problem/16891828>.
Update the standard library, tests, diagnostics, and Fix-Its.

Swift SVN r17981
2014-05-13 00:03:04 +00:00
Argyrios Kyrtzidis
a5eeb9617a [Parser] Create ParamDecls even for unnamed parameters.
This preserves more of source info (e.g. API name location) and simplifies things since
we don't have to construct ParamDecls for the unnamed parameters later on.

Swift SVN r17828
2014-05-10 18:23:47 +00:00
Doug Gregor
ac579592a6 Complain about first keyword arguments in methods/initializers that start with "with".
... with Fix-Its to remove the "with", of course. Only do this under
-implicit-objc-with.

Swift SVN r17755
2014-05-09 01:40:52 +00:00
Argyrios Kyrtzidis
717966f579 [Parser] Emit error + fixit if 'inout' appears after the parameter.
Swift SVN r17518
2014-05-06 01:39:35 +00:00
Argyrios Kyrtzidis
dfa772de8b [AST] Set the source range of ParamDecl as the argument+parameter range and keep track of its parent pattern.
Swift SVN r17441
2014-05-05 15:14:31 +00:00
Chris Lattner
502e663e23 inline parsePatternIdentifier into its only caller, and simplify the result.
Swift SVN r17407
2014-05-04 23:14:15 +00:00
Doug Gregor
eb7a9144a8 Bring keyword arguments to subscripts.
Subscript declarations were still encoding the names of index
variables in the subscript type, which unintentionally made them
keyword arguments. Bring subscript declarations into the modern day,
using compound names to encode the subscript argument names, which
provides consistency for the keyword-argument world
<rdar://problem/14462349>. Note that arguments in subscripts default
to not being keyword arguments, which seems like the right default.

We now get keyword arguments for subscripts, so one can overload
subscripts on the names of the indices, and distinguish at the call
site. Under -strict-keyword-arguments, we require strictness here as well.

The IRGen/IDE/SILGen test updates are because the mangling of common
subscripts changed from accidentally having keyword arguments to not
having keyword arguments.

Swift SVN r17393
2014-05-04 19:31:09 +00:00
Chris Lattner
8f444a4a61 simplify some parsing logic by using Token::isIdentifierOrNone more,
and rearrange some closure parsing logic to tidy it up, NFC.


Swift SVN r17363
2014-05-04 04:42:53 +00:00
Doug Gregor
ca62675c64 Rip out the parsing code for default values in patterns.
This code was already unused.


Swift SVN r17091
2014-04-30 13:59:44 +00:00
Doug Gregor
d003b74c85 An argument with a default value has a keyword argument.
Arguments with default values are one of those places where you
really, really want keyword arguments: make that the default.


Swift SVN r17080
2014-04-30 06:51:43 +00:00
Doug Gregor
0863b2c6ec Operators may never have keyword arguments.
Swift SVN r17071
2014-04-30 04:35:02 +00:00
Doug Gregor
72e32c93af Make argument names default to keyword arguments in the cases where Objective-C has names.
Introduce a model where an argument name is a keyword argument if: 

  - It is an argument to an initializer, or
  - It is an argument to a method after the first argument, or
  - It is preceded by a back-tick (`), or
  - Both a keyword argument name and an internal parameter name are
    specified. 

Provide diagnostics Fix-Its to clean up cases where the user is
probably confused, i.e.,

  - "_ x: Int" -> "x: Int" where "x" would not have been a keyword
  argument anyway
  - "x x: Int" -> "`x: Int"

This covers the compiler side of <rdar://problem/16741975> and
<rdar://problem/16742001>.

Update the AST printer to print in this form, never printing just 
a type for a parameter name because we're also going to adopt
<rdar://problem/16737312> and it was easier to move the tests once
rather than twice.

Standard library and test updates coming separately.




Swift SVN r17056
2014-04-30 00:04:04 +00:00
Doug Gregor
7c8605e6b5 Diagnose use of _ after ` in a parameter declaration; it makes no sense.
Swift SVN r16992
2014-04-28 19:41:02 +00:00
Doug Gregor
2872287dcd Add support for marking function arguments with the back-tick ("`").
Part of <rdar://problem/16742001>. At the moment, this is just a
parsing thing, because argument names are still API by default
anyway.

Swift SVN r16991
2014-04-28 19:35:57 +00:00
Doug Gregor
4e4173f2e6 Remove the "separated" declaration syntax <rdar://problem/16742067>.
Swift SVN r16979
2014-04-28 14:44:53 +00:00
Dmitri Hrybenko
2c88cdfaa3 Fix a crash-on-invalid while parsing a function declaration
rdar://16643959


Swift SVN r16925
2014-04-27 13:57:46 +00:00
Chris Lattner
a9113d7c17 simplify some parsing logic now that function arguments don't have patterns.
Swift SVN r16896
2014-04-26 21:41:58 +00:00
Argyrios Kyrtzidis
6f357713b6 [Parser] Fix assertion hits when trying to print an invalid function.
Swift SVN r16674
2014-04-22 23:21:12 +00:00
Chris Lattner
b204be71cd simplify Parser::isStartOfStmt: just use the current token instead of having
all of the clients pass in the current token.  NFC.


Swift SVN r16601
2014-04-21 04:01:03 +00:00
Doug Gregor
1f4b73b93f Tricky selector-style parameter parsing into creating ParamDecls.
The selector-style parameter parsing code is going away "soon", but we
still need to prop it up a bit longer. Hence, I don't feel too bad
about the Parser-level state I'm using in this hack to make it happen.

With that change, we can now establish two important invariants in the
AST:
  - Only parameters (ParamDecl or GenericTypeParamDecl) can have their
  DeclContexts changed. Everything else comes into being in the
  correct context.
  - All of the parameters in a function/constructor/closure/etc. are
  described by ParamDecls, not just VarDecls.



Swift SVN r16593
2014-04-20 18:25:23 +00:00
Doug Gregor
89ef0af226 Switch subscript index parsing over to a parameter-clause.
Swift SVN r16586
2014-04-20 06:37:47 +00:00
Doug Gregor
997026c6ca Parse closure parameters as a parameter-clause rather than as a pattern.
This means we get ParamDecls rather than VarDecls. Additionally, we
parse both API names and parameter names, although the API names
aren't currently useful. As part of this, loosen up the tentative
parsing that disambiguates between a tuple and a closure
parameter-clause.


Swift SVN r16585
2014-04-20 06:22:12 +00:00
Doug Gregor
09797f7f99 Introduce a new declaration node, ParamDecl, for function parameters.
Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
2014-04-20 05:23:35 +00:00
Doug Gregor
f2053e35ee Start rejecting selector-style declarations, with Fix-Its to tuple-style declarations.
Swift SVN r16455
2014-04-17 16:41:48 +00:00
Doug Gregor
ea647624e3 Eliminate the notion of "selector-style" declarations in the AST.
We still parse them, but the distinction is no longer meaningful
beyond the parsing stage.



Swift SVN r16445
2014-04-17 05:42:58 +00:00
Doug Gregor
8e597cc695 Eliminate argument parameter patterns.
Swift SVN r16444
2014-04-17 05:20:14 +00:00
Doug Gregor
2d70fbad63 Give initializers compound names.
Swift SVN r16404
2014-04-16 07:44:31 +00:00
Doug Gregor
e12afa2e1d Start naming functions more uniformly.
For any function that has a name, ensure that the name is a compound
name with argument names for each of the parameters. 


Swift SVN r16398
2014-04-16 06:05:45 +00:00
Doug Gregor
86ecc725c9 Start building compound names for functions parsed with the new signature style.
Swift SVN r16394
2014-04-16 03:55:05 +00:00
Doug Gregor
18bf604360 Distinguish betweeen simple names ("foo") and zero-argument compound names ("foo()").
This isn't actually used yet, but it's an important distinction.

Swift SVN r16326
2014-04-14 20:05:34 +00:00
Doug Gregor
c1e41584dd Parse the new function syntax for initializers.
Extend parsing of the new function syntax, where both the argument
(API) and parameter (internal) name are specified prior to the colon,
to initializers.


Swift SVN r16311
2014-04-14 14:19:53 +00:00
Dmitri Hrybenko
f90e0c153b Make 'override' a keyword
rdar://16462192

Swift SVN r16115
2014-04-09 14:19:50 +00:00
Dmitri Hrybenko
3d404e3749 Remove dead argument parsing code
Swift SVN r16051
2014-04-08 08:28:37 +00:00
Doug Gregor
6da952e798 Parse the new function syntax.
Parse the new function syntax, which allows both the argument (API)
and parameter (internal) name to be specified prior to the colon
within each parameter. Don't re-use the existing pattern-parsing
logic. Rather, implement a new (far simpler) parser for this purpose,
then map from its simple data structures to ArgParams and BodyParams
as we're used to.

There are a number of caveats here:
  - We no longer have the ability to use patterns for parameters in
  function declarations. The only place this really has an impact is
  that it makes the ~> hack in the standard library even uglier.
  - This exposed some issues with code completion with generic
  parameters that need to be investigated.
  - There's still some work to be done to improve recovery when things
  parse poorly within a parameter list; there are some XFAILs to deal
  with that.

I'll address the last two issues with follow-up commits.

Swift SVN r15967
2014-04-05 00:21:06 +00:00
Doug Gregor
527b147ba7 Revert "Allow the first name of a selector-style function declaration to be separated."
This reverts r15140.

Conflicts:
	include/swift/Serialization/ModuleFormat.h
	lib/Parse/ParsePattern.cpp

Swift SVN r15846
2014-04-02 23:27:52 +00:00
Doug Gregor
9189145cc5 Change DeclName over to basename(arg1:arg2:...argN:).
Swift will use the basename + argument names formulation for
names. Update the DeclName interfaces, printing, and __FUNCTION__ to
use the method syntax.

We'll still need to rework the "x.foo:bar:wibble:" syntax; that will
come (significantly) later.

Swift SVN r15763
2014-04-02 00:00:03 +00:00