This allows an elegant design in which we can still allocate RawSyntax
nodes using a bump allocator but are able to automatically free that
buffer once the last RawSyntax node within that buffer is freed.
This also resolves a memory leak of RawSyntax nodes that was caused by
ParserUnit not freeing its underlying ASTContext.
At the time this logic was introduced in 8f83ca67, `<expr>.<keyword>` wasn't
allowed. Now that SE-0071 has been implemented, this logic doesn't provide any
positive effects.
* Handle completion in 'parseExprKeyPath()' instead of
'parseExprPostfixSuffix()'.
* Fix a crash for implicit type keypath. e.g. '\.path.<complete>'. (SR-8042).
* Use 'completeExprKeyPath()' callback.
* Implement completion without '.'. e.g. '\Ty.path<complete>'
* Improved handling for 'subscript' in completion.
* Improved handling for optional unwrapping in completion.
https://bugs.swift.org/browse/SR-8042
rdar://problem/41262612
* Consolidate CompletionKind::KeyPathExpr and CompletionKind::KeyPathExprDot
to CompletionKind::KeyPathExprObjC
* Make completeKeyPath() to receive DotLoc.
Using dummy UnresolvedMemberExpr doesn't give us much benefit. Instead, use
CodeCompletionExpr which is type checked as type variable so can use
CodeCompletionTypeContextAnalyzer to infer context types.
This way, we can eliminate most of special logic for UnresolvedMember.
rdar://problem/39098974
The parser was using an AST-level name lookup operation to provide a
slightly improved diagnostic (suggesting "self." if there was a member
of that name in the enclosing type context). This is a fairly unfortunate
layering violation: name lookup cannot produce correct results at this
point. Remove the custom diagnostic and the lookup; this can come back
when all lookup moves out of the parser.
* [Parser] Keep source location info for the ownership keywords inside a closure capture list
This allows to do syntax coloring for 'weak'/'unowned' inside a capture list
rdar://42655051
In Swift3, shadowning type(of:) was impossible, because it was a parser
magic. In Swift4, type(of:) is resolved as normal function in stdlib so
it can be shadowed. 'TypeOfMigratorPass' was a targeted migrator pass
that prepend 'Swift.' to 'type(of:)' so that it refers Swift.type(of:)
stdlib builtin function.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.
`_read` accessors do not make any effort yet to avoid copying the
value being yielded. I'll work on it in follow-up patches.
Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.
SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.
rdar://35399664
Pass through the location of the equal '=' token for pattern binding decl entries, and use this location for the immediate deallocation diagnostic. Previously, we were just diagnosing on the start of the initialiser expression.
Additionally, this commit moves the call to `diagnoseUnownedImmediateDeallocation` from `typeCheckBinding` to `typeCheckPatternBinding`. This not only gives us easier access to the PBD entry, but also avoids calling the diagnostic logic for statement conditions such as `if let x = <expr>`. We currently never diagnose on these anyway, as the 'weak' and 'unowned' keywords cannot be applied to such bindings.
Resolves [SR-7340](https://bugs.swift.org/browse/SR-7340).
Currently when call involving prefix/postfix operator is formed we
don't wrap argument in implicit parens (like we do with other calls)
when user didn't provide any explicitly, this is bad because
argument-to-parameter matcher requires multiple special cases to handle
such behavior, so let's start wrapping arguments in implicit parens instead.
Resolves: rdar://problem/40722855
Resolves: [SR-7840](https://bugs.swift.org/browse/SR-7840)
* Reject bad string interpolations
String interpolations with multiple comma-separate expressions or argument labels were being incorrectly accepted.
* Tweak error name to match message
* Diagnose empty interpolations more clearly
* Don’t double-diagnose parse errors
Fixes a test at Parse/recovery.swift:799 which the previous commit broke.
* Fix incorrect test RUN: line
A previous version of this test used FileCheck instead of -verify, and the run line wasn’t properly corrected to use -verify.
* Update comment
* Add more argument label tests
Ensures that we don’t get different results from an initializer that doesn’t exist or doesn’t take a String.
* Resolve the SR-7958 crasher test
We now diagnose the error and remove the label before it has an opportunity to crash.
LLVM r334399 (and related Clang changes) moved clang::VersionTuple to
llvm::VersionTuple. Update Swift to match.
Patch by Jason Molenda.
rdar://problem/41025046
Trying to diagnose extraneous use of `&` in parser is too early
and affects some valid cases like patterns in `case` statements,
where we still want to allow use of `&`.
Made an utility method 'consumeArgumentLabel', and use it for:
* Labels in tuple type
* Labels in tuple expression
* Argument and parameter names in parameter clause
This also fixes several issues where attribute arguments could not be
parsed as a TokenList since some of its arguments already had structure
and were not tokens
Resetting Lexer to the start of the line result re-tokenizning whole
string literal as a single token, and go past artificial EOF.
This used to end up with assertion failure or infinite-loop in
no-assertion builds.
Quick fix for: rdar://problem/36881302
The amp_prefix token is currently tolerated in any unary expression
context and then diagnosed later by Sema. This patch changes parsing to
only accept tok::amp_prefix in its allowed position: parameter lists.
This also fixes two "compiler crasher" tests.