Commit Graph

116 Commits

Author SHA1 Message Date
Chris Lattner
7724e92955 this test is fixed.
Swift SVN r28109
2015-05-04 04:01:45 +00:00
Chris Lattner
f3416ab719 fix a bug introduced in r28104: we need to create a PBD to hold the vardecls
we parsed, otherwise the type checker gets confused later.  This fixes these
regressions:

    Swift :: compiler_crashers_fixed/0725-swift-type-walk.swift
    Swift :: compiler_crashers_fixed/0742-swift-metatypetype-get.swift
    Swift :: compiler_crashers_fixed/1501-swift-diagnosticengine-flushactivediagnostic.swift
    Swift :: compiler_crashers_fixed/1705-vtable.swift

Also, that patch fixed 0791-swift-type-walk.swift, so mark it as not crashing.


Swift SVN r28108
2015-05-04 04:01:28 +00:00
Doug Gregor
5de47e93dd Remove uses of getProtocols() from serialization.
NFC except for having to work around the brokenness of
-enable-source-import in more places.

Swift SVN r27979
2015-04-30 16:13:45 +00:00
Doug Gregor
d0282e0d62 Switch the AST printer over to getLocalProtocols().
Swift SVN r27968
2015-04-30 16:13:37 +00:00
Chris Lattner
31c01eab73 Change the meaning of "if let x = foo()" back to Xcode 6.4 semantics. The compiler
includes a number of QoI things to help people write the correct code.  I will commit
the testcase for it as the next patch.

The bulk of this patch is moving the stdlib, testsuite and validation testsuite to
the new syntax.  I moved a few uses of "as" patterns back to as? expressions in the 
stdlib as well.



Swift SVN r27959
2015-04-30 04:38:13 +00:00
Dmitri Hrybenko
7e73f16ba5 The crash test #0272 passes on Linux, annotate it as such
Swift SVN r27578
2015-04-22 08:50:21 +00:00
Doug Gregor
69718f77fa When failing to find a suitable type witness, always record ErrorType.
Fixes the crash in rdar://problem/20564378. In these cases, we end up
swallowing some diagnostics. That will be addressed in a subsequent
commit.

Swift SVN r27436
2015-04-17 18:11:35 +00:00
Doug Gregor
997136962e Always open existential types in the type checker.
Consistently open all references into existentials into
opened-existential archetypes within the constraint solver. Then,
during constraint application, use OpenExistentialExprs to record in
the AST where an existential is opened into an archetype, then use
that archetype throughout the subexpression. This simplifies the
overall representation, since we don't end up with a mix of operations
on existentials and operations on archetypes; it's all archetypes,
which tend to have better support down the line in SILGen already.

Start simplifying the code in SILGen by taking away the existential
paths that are no longer needed. I suspect there are more
simplifications to be had here.

The rules for placing OpenExistentialExprs are still a bit ad hoc;
this will get cleaned up later so that we can centralize that
information. Indeed, the one regression in the compiler-crasher suite
is because we're not closing out an open existential along an error
path.

Swift SVN r27230
2015-04-11 03:20:22 +00:00
Jordan Rose
cc45a8e86a [test] Don't run still-crashing compiler_crashers under no-asserts builds.
Per discussion on the list. From now on, when you fix a compiler_crashers
test case, move it to compiler_crashers_fixed so that we get no-asserts and
ASan coverage.

Swift SVN r27055
2015-04-07 03:05:02 +00:00
Mark Lacey
c3245dac9a Update tests that pass in no-assertions builds so that they do not run.
Also remove one 'XFAIL: no_asserts' in a test that no longer fails in
no-asserts builds.

Swift SVN r26965
2015-04-04 00:29:08 +00:00
Chris Lattner
192da7e0bf it looks like my changes regressed this test, xfail it for now.
Swift SVN r26960
2015-04-03 23:11:25 +00:00
Mark Lacey
0fcea2dbb5 Remove XFAIL as this passes with no-asserts builds.
Swift SVN r26947
2015-04-03 19:05:31 +00:00
Mark Lacey
3290b0dd0f Fix run line for real this time.
This test compiles successfully.

Swift SVN r26917
2015-04-02 23:44:37 +00:00
Mark Lacey
c85afb8405 Fix run line of compiler crasher that no longer crashes.
Apparently fixed by tuple-related fixes that went in today.

Swift SVN r26915
2015-04-02 23:25:24 +00:00
Chris Willmore
690daa539a Back out changes for in-place methods/operators from Xcode 7.
This reverts commits r26508, r26545, and r26576.

Swift SVN r26900
2015-04-02 21:14:28 +00:00
Ted Kremenek
a01843b291 Disable running compiler_crashers tests when using Address Sanitizer.
Swift SVN r26759
2015-03-31 15:15:14 +00:00
Ted Kremenek
1d393307a9 Mark 0066-diagnoseunknowntype.swift to have an expected failure under ASan.
Swift SVN r26727
2015-03-30 21:18:42 +00:00
Chris Lattner
21b2e9e057 add parser and AST representation support for where/else clauses on let/var decls, some highlights:
- Enhance PBD with a whereExpr/elseStmt field to hold this.
- Start parsing the pattern of let/var decls as a potentially refutable pattern.  It becomes 
  a semantic error to use a refutable pattern without an 'else' (diagnostics not in place yet).
- Change validatePatternBindingDecl to use 'defer' instead of a goto to ensure cleanups on exit.
- Have it resolve the pattern in a PBD, rewriting it from expressions into pattern nodes when valid.
- Teach resolvePattern to handle TypedPatterns now that they can appear (wrapping) refutable patterns.
- Teach resolvePattern to handle refutable patterns in PBD's without initializers by emitting a diagnostic
  instead of by barfing, fixing regressions on validation tests my previous patch caused, and fixing
  two existing validation test crashers.

Sema, silgen, and more tests coming later.




Swift SVN r26706
2015-03-29 22:08:44 +00:00
Doug Gregor
2609a971b6 Perform name lookup for where clauses based on the generic parameter's context.
We were ending up looking in the parent context, but it didn't matter
because the parser pre-resolved the names of generic parameters. We
shouldn't be relying on the parser to do that.

Note that this regresses four compiler crashes, because they end up
looking back into their own generic parameter lists in unhealthy
ways. I'm going to temporarily burn some karma because of what this
enables...

Swift SVN r26688
2015-03-29 05:42:33 +00:00
Doug Gregor
d4d4694615 Introduce a few defensive null checks to fix 157 compiler crashers.
Swift SVN r26655
2015-03-27 23:57:45 +00:00
Doug Gregor
1bbcb913a3 Clean up some "XFAIL: asan"'s that are no longer valid.
Swift SVN r26596
2015-03-26 18:04:18 +00:00
Doug Gregor
3d77855b31 Start allowing extensions of protocol types.
Remove the semantic restrictions that prohibited extensions of
protocol types, and start making some systematic changes so that
protocol extensions start to make sense:
  - Replace a lot of occurrences of isa<ProtocolDecl> and
    dyn_cast<ProtocolDecl> on DeclContexts to use the new
    DeclContext::isProtocolOrProtocolExtensionContext(), where we want
    that behavior to apply equally to protocols and protocol extensions.
  - Eliminate ProtocolDecl::getSelf() in favor of
    DeclContext::getProtocolSelf(), which produces the appropriate
    generic type parameter for the 'Self' of a protocol or protocol
    extension. Update all of the callers of ProtocolDecl::getSelf()
    appropriately.
  - Update extension validation to appropriately form generic
    parameter lists for protocol extensions.
  - Methods in protocol extensions always use the witnesscc calling
  convention.

At this point, we can type check and SILGen very basic definitions of
protocol extensions with methods that can call protocol requirements,
generic free functions, and other methods within the same protocol
extension.

Regresses four compiler crashers but improves three compiler
crashers... we'll call that "progress"; the four regressions all hit
the same assertion in the constraint system that will likely be
addressed as protocol extensions starts working.

Swift SVN r26579
2015-03-26 04:50:51 +00:00
Doug Gregor
cce9081fe2 Teach getSelfTypeForContainer() that it's rude to crash when the container has no type.
Fixes 68 crashes in the compiler-crashers suite.

Swift SVN r26564
2015-03-25 23:20:59 +00:00
Chris Willmore
972d0d6cba Compiler crasher 1293 no longer crashes after r26508.
Swift SVN r26545
2015-03-25 18:46:50 +00:00
Doug Gregor
a18cd9849c Update compiler crashers that don't fully crash under ASan.
rdar://problem/20198158

Swift SVN r26505
2015-03-24 23:43:56 +00:00
Doug Gregor
7677a454ea Move "non-self-conforming protocol type" check out of type validation.
Having semantic checking in type validation introduces the potential for more recursion, triggering crashes. By moving this semantic restriction out to a later stage, we make it more robust. Fixes 6 compiler crashers, although it regressed one compiler crasher that hits a different known issue (assertions in addGenericParameters when we have multiple parameters at the same depth).

Swift SVN r26226
2015-03-17 16:34:28 +00:00
Chris Lattner
59c22383fb Rework PatternBindingDecl to maintain a list of pattern/initexpr pairs inside of it.
Previously, a multi-pattern var/let decl like:
  var x = 4, y = 17

would produce two pattern binding decls (one for x=4 one for y=17).  This is convenient
in some ways, but is bad for source reproducibility from the ASTs (see, e.g. the improvements
in test/IDE/structure.swift and test/decl/inherit/initializer.swift).

The hardest part of this change was to get parseDeclVar to set up the AST in a way
compatible with our existing assumptions. I ended up with an approach that forms PBDs in 
more erroneous cases than before.  One downside of this is that we now produce a spurious
  "type annotation missing in pattern"
diagnostic in some cases.  I'll take care of that in a follow-on patch.





Swift SVN r26224
2015-03-17 16:14:18 +00:00
Chris Lattner
bf643410d6 tweaks to the validation test RUN lines.
Swift SVN r26181
2015-03-16 15:06:28 +00:00
Chris Lattner
ce9b0131a1 Change the testsuite to not use typed patterns in nested contexts, which
requires pushing the types out.  The only interesting one is this diff:

-  var (e,f,g:(),h) = MRV()
+  var (e,f,g,h) : (Int, Float, (), Double) = MRV()

... where the type annotation is required to silence the warning about "void type
may be unexpected".  This seems perfectly reasonable to me.



Swift SVN r26161
2015-03-15 19:11:18 +00:00
Chris Lattner
20f8f09ea8 Land: <rdar://problem/19382905> improve 'if let' to support refutable patterns and untie it from optionals
This changes 'if let' conditions to take general refutable patterns, instead of
taking a irrefutable pattern and implicitly matching against an optional.

Where before you might have written:
  if let x = foo() {

you now need to write:
  if let x? = foo() {
    
The upshot of this is that you can write anything in an 'if let' that you can
write in a 'case let' in a switch statement, which is pretty general.

To aid with migration, this special cases certain really common patterns like
the above (and any other irrefutable cases, like "if let (a,b) = foo()", and
tells you where to insert the ?.  It also special cases type annotations like
"if let x : AnyObject = " since they are no longer allowed.

For transitional purposes, I have intentionally downgraded the most common
diagnostic into a warning instead of an error.  This means that you'll get:

t.swift:26:10: warning: condition requires a refutable pattern match; did you mean to match an optional?
if let a = f() {
       ^
        ?

I think this is important to stage in, because this is a pretty significant
source breaking change and not everyone internally may want to deal with it
at the same time.  I filed 20166013 to remember to upgrade this to an error.

In addition to being a nice user feature, this is a nice cleanup of the guts
of the compiler, since it eliminates the "isConditional()" bit from
PatternBindingDecl, along with the special case logic in the compiler to handle
it (which variously added and removed Optional around these things).




Swift SVN r26150
2015-03-15 07:06:22 +00:00
Dmitri Hrybenko
445d51c551 Annotate tests that don't crash under AddressSanitizer anymore
Swift SVN r26096
2015-03-13 07:42:45 +00:00
Chris Lattner
718d82f5c9 rework our treatment of identifiers in refutable patterns that are inside of
a let/var pattern.  Now any identifier in one of these is a variable binding,
not sometimes a value references (depending on contextual syntax).

This isn't expected to have a widespread effect on existing real world code:
 - No impact on the stdlib.
 - It does fix two validation crash tests, but possibly because the original issue is hidden by a different diagnostic path in the compiler.
 - This needed two tests to be tweaked to undistribute "let".

On the positive side, this means that "case let x?:" now works properly, woo.



Swift SVN r26000
2015-03-11 23:08:55 +00:00
Dmitri Hrybenko
c31c286932 Annotate valiation tests that don't crash without assertions anymore
Swift SVN r25970
2015-03-11 05:46:04 +00:00
Graham Batty
7346a9733d Update test and validation-test flags for linux.
Swift SVN r25506
2015-02-24 18:55:42 +00:00
Dmitri Hrybenko
10d8533e4b XFAIL the new regressions under AddressSanitizer
<rdar://problem/19919467> Interpreter/repl.swift regressed under ASan
<rdar://problem/19919459>
compiler_crashers/0214-swift-typebase-gettypeofmember.swift regressed
under ASan

Swift SVN r25483
2015-02-23 10:34:31 +00:00
Doug Gregor
a3b4b0903b Teach TypeChecker::resolveTypeInContext to use interface types more often.
When referring to a type declaration that is a member of some nominal
type, we were relying on substitution into the non-interface type,
which is silly. Use the interface type here.

Other than some type-printing differences, this should be NFC.

Slight regression in two compiler crashes that had been fixed in the
previous commit; I'll look into these shortly.

Swift SVN r25385
2015-02-19 00:58:44 +00:00
Doug Gregor
a34a457ce7 Teach TypeDecl::getDeclared(Interface)Type() about ErrorType.
Propagate the error rather than crashing. Fixes 25 crashes from the
test suite, covered by rdar://problem/19883429.

Swift SVN r25384
2015-02-19 00:58:42 +00:00
Dmitri Hrybenko
05906dbc16 Annotate crash tests that don't crash when the compiler is built without
assertions

Swift SVN r25350
2015-02-17 05:04:20 +00:00
Dmitri Hrybenko
d14dd26372 Annotate a crash test that does not crash anymore
Swift SVN r25348
2015-02-17 03:49:58 +00:00
Dmitri Hrybenko
90b6348029 Annotate crasher tests where ASan does not detect issues anymore
Swift SVN r25297
2015-02-14 13:07:14 +00:00
Dmitri Hrybenko
8459b8418f Annotate two crash tests that don't crash anymore
Swift SVN r25296
2015-02-14 12:59:19 +00:00
Jordan Rose
e635d6a993 In the spirit of r25276, break circularity with generic functions, too.
Also beef up the main test case a little.

I don't have a Radar, but this fixes 177 compiler_crashers!

Swift SVN r25281
2015-02-13 19:59:48 +00:00
Jordan Rose
b2dd3cea7c Update compiler_crashers for r25276.
Swift SVN r25277
2015-02-13 19:20:21 +00:00
Dmitri Hrybenko
38a14768e7 Annotate a crasher test that is not crashing anymore
Swift SVN r25223
2015-02-12 02:29:00 +00:00
Joe Groff
63463f54ac SIL: Mangle the static-ness of declarations.
This lets us disambiguate the symbols for static and instance properties, and enables us to eventually leave the useless "self" type mangling out of method symbols. Fixes rdar://19012022 and dupes thereof, including crasher #1341.

Swift SVN r25111
2015-02-10 02:37:35 +00:00
Jordan Rose
1e4f4b1939 Update fixed compiler crashers for r25059.
Swift SVN r25066
2015-02-07 04:09:32 +00:00
Dmitri Hrybenko
f3972edecd Annotate a crash test that does not crash now
Swift SVN r24992
2015-02-05 05:31:35 +00:00
Dmitri Hrybenko
eae39871bc Annotate tests that no longer crash under AddressSanitizer
Swift SVN r24988
2015-02-05 02:44:55 +00:00
Doug Gregor
e855ae8f58 Clang importer: only consider imported initializers when filtering out duplicates.
Fixes rdar://problem/18500201 and 16 of the crashes in the crash suite.

Swift SVN r24982
2015-02-05 00:07:58 +00:00
Dmitri Hrybenko
de14227634 validation-test: annotate test that started hitting an assertion
Swift SVN r24979
2015-02-04 23:41:59 +00:00