Commit Graph

20 Commits

Author SHA1 Message Date
Daniel Duan
780b58a9a5 [Parser] update tests for 'inout' syntax adjustment 2016-02-26 01:33:22 -08:00
David Farler
3f635d04c7 Reinstante var bindings in refutable patterns, except function parameters.
This reverts commits: b96e06da44,
                      8f2fbdc93a,
                      93b6962478,
                      64024118f4,
                      a759ca9141,
                      3434f9642b,
                      9f33429891,
                      47c043e8a6.

This commit leaves 'var' on function parameters as a warning to be
merged into Swift 2.2. For Swift 3, this will be an error, to be
converted in a follow-up.
2016-01-29 15:27:08 -08:00
Chris Willmore
983a674e0c Make use of curried function declaration syntax an error.
<rdar://problem/23111018>
2016-01-20 21:57:38 -08:00
Chris Willmore
30af42fda9 Add warning that curried function decl syntax is going away.
<rdar://problem/23111018>
2015-11-02 15:45:11 -08:00
David Farler
3434f9642b Disallow 'var' pattern bindings in if, while, and guard statements
Make the following patterns illegal:

  if var x = ... {
    ...
  }

  guard var x = ... else {
    ...
  }

  while var x = ... {
    ...
  }

And provide a replacement fixit 'var' -> 'let'.

rdar://problem/23172698

Swift SVN r32855
2015-10-24 01:46:30 +00:00
Jordan Rose
64100010dd Allow capturing from another TopLevelCodeDecl.
Otherwise, we'll fail to capture "locals" declared in top-level guard
statements. This led to an assertion failure in SILGen.

Depends on previous commit.

rdar://problem/21997265

Swift SVN r30812
2015-07-30 19:47:58 +00:00
Chris Lattner
0e20f24b95 fix <rdar://problem/18734297> Reject access to local variables from local types
init()'s implicitly evaluate the initial values for properties, and we aren't modeling
that correctly in the AST.  This prevented the closure checker from noticing these 
accesses, leading to SILGen crashing later.  In the absence of proper AST modeling of
this, add special case handling for them.



Swift SVN r29508
2015-06-19 06:15:19 +00:00
Slava Pestov
7319a97ab4 Sema: Rewrite witness method calls as ApplyExpr + DeclRefExpr
Special-casing these as MemberRefExprs created an asymmetry
where unbound archetype instance methods (<T : P> T.f) could
not be represented. Treating class and protocol methods
uniformly also eliminates a handful of special cases around
MemberRefExpr.

SILGen's RValue and call emission peepholes now have to know
about DeclRefExprs that point to protocol methods.

Finally, generalize the diagnostic for partially applied
mutating methods to any partially applied function with an
inout parameter, since this is not supported.

Fixes <rdar://problem/20564672>.

Swift SVN r29298
2015-06-04 15:57:58 +00:00
Slava Pestov
8eabf84450 Sema: diagnose capturing type declarations for now
Properly implementing a class whose methods capture variables
defined in the outer scope requires adding the captures as
hidden vars in the class and initializers, and seems
non-trivial.

Just diagnose this case for now instead of crashing.

Fixes <rdar://problem/20853958>.

Swift SVN r28481
2015-05-12 18:19:37 +00:00
Chris Lattner
4366da9250 more testcase updates for upcoming diagnostics change.
Swift SVN r28409
2015-05-11 06:05:00 +00:00
Joe Groff
91ade9444d Sema: Allow mutual recursion of local functions.
Local functions may reference each other as long as they don't transitively capture any vars or other non-function local decls before their declaration.

Swift SVN r28394
2015-05-10 16:53:39 +00:00
Jordan Rose
f54e3570a3 Preserve the location of the 'in' when doing void-conversion on a closure.
This location is used when deciding whether a capture has already been
initialized, and without it the compiler decides that the reference to
a name from the capture list should be rejected.

rdar://problem/19776255&20153574

Swift SVN r26103
2015-03-13 17:35:14 +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
Doug Gregor
f8409eb025 Print location in expression AST dumps as well
Swift SVN r18559
2014-05-22 07:41:31 +00:00
Doug Gregor
f11e992f23 A local cannot be captured before it is declared <rdar://problem/16747992>.
Swift SVN r18025
2014-05-13 21:28:09 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Doug Gregor
1082ea51a0 Actual use location information when looking for local variables.
This addresses the bulk of <rdar://problem/15344950>, which involes us
not being able to find local variable declarations in expressions when
the parser didn't pre-bind them for us.

The fix to name lookup itself insures that a case such as 
  case (var a, a)

doesn't allow the second 'a' to find the first.


Swift SVN r9858
2013-10-31 22:56:02 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Doug Gregor
6337523879 Compute captures from the leaves up to the root.
Fixes <rdar://problem/13249017>.


Swift SVN r5049
2013-05-06 16:14:38 +00:00
Doug Gregor
7c2f86d948 Prohibit capture of [byref] parameters.
There is a special-case hack to allow capture of 'this', which is
implicitly [byref] for structs. At the moment, most of the cases where
this hack is necessary are [auto_closure] parameters (for assertions
and &&/||).



Swift SVN r5047
2013-05-06 14:54:22 +00:00