Commit Graph

104 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
bbdada475b [Parse] Try to preserve the invariant that anything that contains KeyPathDotExpr must be wrapped in KeyPathExpr
Even in the presence of invalid code. Fixes typechecker crash in rdar://50666427
2020-02-20 15:07:00 -08:00
Slava Pestov
1d2d653844 IDE: Redo typeCheckContext()
- Don't type check top-level contexts multiple times
- Use validateDecl() instead of typeCheckDecl() when possible
2018-06-30 00:20:37 -07:00
Slava Pestov
e58ae766a3 Fix and un-XFAIL regressed crashers from recent stdlib change 2017-05-17 05:51:51 -07:00
Maxim Moiseev
1c1b2b966d [stdlib] String : RangeReplaceableCollection & BidirectionalCollection (#8921)
* [stdlib] String : RangeReplaceableCollection & BidirectionalCollection

* Add source compatibility hack for Swift.max

* Add source compatibility hack for Swift.min

* Remove redundant conformance in benchmarks

* Fix stupid typo I thought I'd already pushed

* XFAIL testing now-redundant conformance

* XFAIL an IDE test for now
2017-04-23 20:04:54 -07:00
Slava Pestov
e063e8297c Sema: Some fixes for the ITC
- In functions called from resolveType(), consistently
  use a Type() return value to indicate 'unsatisfied
  dependency', and ErrorType to indicate failure.

- Plumb the unsatisfiedDependency callback through the
  resolution of the arguments of BoundGenericTypes, and
  also pass down the options.

- Before doing a conformance check on the argument of a
  BoundGenericType, kick off a TypeCheckSuperclass request
  if the type in question is a class. This ensures we don't
  recurse through NominalTypeDecl::prepareConformanceTable(),
  which wants to see a class with a valid superclass.

- The ResolveTypeOfDecl request was assuming that
  the request was satisfied after calling validateDecl().
  This is not the case when the ITC is invoked from a
  recursive call to validateDecl(), hack this up by returning
  *true* from isResolveTypeDeclSatisfied(); otherwise we
  assert in satisfy(), and we can't make forward progress
  in this case anyway.

- Fix a bug in cycle breaking; it seems if we don't invoke
  the cycle break callback on all pending requests, we end
  up looping forever in an outer call to satisfy().

- Remove unused TR_GlobalTypeAlias option.
2016-12-09 17:36:49 -08:00
Xi Ge
6bbdf4a837 [Mangler] Check the order of generic type parameters before mangling them to avoid assertion hit. 2016-12-09 09:51:40 -08:00
Jordan Rose
49e6c06eef [validation-test] Remove "REQUIRES: asserts" from /fixed/ crash cases. (#6156) 2016-12-08 19:06:32 -08:00
Xi Ge
54e8527d5c [code-completion] Ensure consumeDecl() does not alter the state of parser. (#6110)
This also fixes IDE/crashers/029-swift-decl-walk.swift.
2016-12-06 16:01:29 -08:00
Ben Langmuir
ef7f8f7c9a Merge pull request #6102 from benlangmuir/fix-032
[code-completion] Allow ErrorType in solution to avoid assertion failure
2016-12-06 12:26:33 -08:00
Ben Langmuir
49f144205f Merge pull request #6085 from nathawes/rdar28867801
[code-completion] Fix crash in printParameterList when paramListTy is…
2016-12-06 11:46:26 -08:00
Ben Langmuir
c01bff7ddb [code-completion] Allow ErrorType in solution to avoid assertion failure
When CSGen encounters an error it may set a type to ErrorType, but the
system will still "solve".
2016-12-06 10:42:16 -08:00
Slava Pestov
dbdb8d62ea Merge pull request #6094 from slavapestov/cleanup-generic-resolver-workaround
Cleanup generic resolver workaround
2016-12-06 10:24:18 -08:00
Slava Pestov
fdaa886065 Sema: Rework resolveTypeInContext()
Separate the "find the correct context" part from "substitute in the
base type" part. The former can go away completely after a bit of
refactoring.
2016-12-06 09:39:28 -08:00
swift-ci
20c44e6de4 Merge pull request #6095 from akyrtzi/fix-ide-crash-103 2016-12-06 09:06:31 -08:00
Argyrios Kyrtzidis
7a390e1fac [code-completion] Improve robustness of Solution::computeSubstitutions and check if OpenedTypes contains the provided locator.
Fixes validation-test/IDE/crashers/103-swift-constraints-solution-resolvelocatortodecl.swift.
2016-12-06 08:28:53 -08:00
Xi Ge
1f7a5f4412 Fixing /IDE/crashers/016-swift-mangle-mangler-mangleidentifier.swift (#6079) 2016-12-05 21:20:35 -08:00
Xi Ge
1570f8e4f1 Fixing IDE/crashers/091-swift-typechecker-computedefaultaccessibility.swift (#6084) 2016-12-05 20:52:07 -08:00
swift-ci
e0bec70809 Merge pull request #6090 from bitjammer/guard-null-generic-env 2016-12-05 19:59:12 -08:00
David Farler
25e623addb Don't resolve a generic type parameter type from null environments
The generic environment of a GenericTypeToArchetypeResolver may be
`nullptr`, as returned by DeclContext::getGenericEnvironmentOfContext,
during prechecking of closure expressions at the necessarily non-generic
top level.

Fixes a couple of crashers.
2016-12-05 19:34:02 -08:00
swift-ci
5b822979a1 Merge pull request #6088 from bitjammer/correct-utf-8-illegal-octets 2016-12-05 17:51:10 -08:00
swift-ci
de858041e7 Merge pull request #6087 from akyrtzi/fix-ide-crash-084 2016-12-05 17:51:09 -08:00
David Farler
330c2d96e6 Make the lexer UTF-8 RFC 3629 correct re: prefix octets
RFC 2279 states that, in UTF-8:
"The octet values FE and FF never appear."

RFC 3629 states that, in UTF-8:
"The octet values C0, C1, F5 to FF never appear."

Generalize the check to advance past invalid starting bytes for
a UTF-8 sequence to fix a crash in the lexer.
2016-12-05 17:21:17 -08:00
Argyrios Kyrtzidis
fc678740db [code-completion] Avoid a tentantive parse when in code-completion mode and make sure CodeCompletionExpr has a token range.
The tentantive parse is used for diagnostic purposes but can cause code-completion to delay the same decl twice.
The range of CodeCompletionExpr was previously character range which invalidated invariants of the AST.

Fixes:
	validation-test/IDE/crashers_fixed/084-swift-parser-consumedecl.swift
	validation-test/IDE/crashers_fixed/104-swift-gettypeofcompletioncontextexpr.swift
2016-12-05 17:09:49 -08:00
Nathan Hawes
528f38aadb [code-completion] Fix crash in printParameterList when paramListTy is Error type rdar://problem/28867801 2016-12-05 15:16:13 -08:00
Argyrios Kyrtzidis
b0705b455a [code-completion] Fix assertion hit when calling 'DeclContext::getResilienceExpansion()' with invalid code
Fixes:
	validation-test/IDE/crashers/074-swift-valuedecl-geteffectiveaccess.swift
	validation-test/IDE/crashers/095-swift-declcontext-getresilienceexpansion.swift
2016-12-05 14:39:53 -08:00
swift-ci
796994cd80 Merge pull request #6080 from akyrtzi/fix-crash-014 2016-12-05 13:30:31 -08:00
Argyrios Kyrtzidis
f548c2ba52 [code-completion] Fix assertion hit when completing after incomplete property.
Make sure to call getPtrOrNull() instead of get() directly.
2016-12-05 12:48:48 -08:00
swift-ci
159a1d93a2 Merge pull request #6077 from nkcsgexi/ide-crash-012 2016-12-05 12:29:03 -08:00
swift-ci
c14391de1f Merge pull request #6076 from benlangmuir/fix-040 2016-12-05 12:16:08 -08:00
Xi Ge
5699b5a1e0 Fixing /IDE/crashers/012-swift-mangle-mangler-manglecontext.swift 2016-12-05 11:55:21 -08:00
Ben Langmuir
1ca799bfda [code-completion] Fix crash in typeCheckConstructorBodyUntil with null nominal context
With erroneous code, such as in code-completion, it's not safe to assume
that the constructor is inside a nominal decl context.

rdar://problem/28867794
2016-12-05 11:52:18 -08:00
Ben Langmuir
9894eeda45 [code-completion] Fix crash with missing func body in type-checking
We already fail early on a missing body in normal type-checking, but we
missed the case where we call typeCheckAbstractFunctionBodyUntil
directly, as in code-completion.

rdar://problem/28822204
2016-12-05 10:42:56 -08:00
Doug Gregor
46e6a38e50 Mark three crashers as resolved 2016-12-01 15:25:43 -08:00
Slava Pestov
7b59e75d34 IDE: hasType() => hasInterfaceType() 2016-11-29 03:05:31 -07:00
Slava Pestov
044034cae5 Sema: hasType() => hasInterfaceType() 2016-11-29 03:05:31 -07:00
Slava Pestov
6cbb494ad2 AST: Give all ValueDecls an interface type
Previously, getInterfaceType() would return getType() if no
interface type was set. Instead, always set an interface type
explicitly.

Eventually we want to remove getType() altogether, and this
brings us one step closer to this goal.

Note that ParamDecls are excempt from this treatment, because
they don't have a proper interface type yet. Cleaning this up
requires more effort.
2016-11-29 03:05:25 -07:00
Slava Pestov
ea28765ced Sema: Resolve invalid generic parameters to error types
When a generic parameter list fails to parse, we don't call
DeclContext::setGenericParams(), even though the generic
parameters are still available for name lookup.

This causes various crashes, which this patch fixes by
mapping the generic parameters to ErrorTypes.
2016-11-26 01:31:59 -05:00
Graydon Hoare
7c1dc18b64 Revert "Give all declarations an explicit interface type" 2016-11-24 09:55:27 -08:00
Slava Pestov
ee56292808 AST: Give all ValueDecls an interface type
Previously, getInterfaceType() would return getType() if no
interface type was set. Instead, always set an interface type
explicitly.

Eventually we want to remove getType() altogether, and this
brings us one step closer to this goal.

Note that ParamDecls are excempt from this treatment, because
they don't have a proper interface type yet. Cleaning this up
requires more effort.
2016-11-24 02:35:21 -05:00
Ben Langmuir
fe2c0db53b [code-completion] Fix completion when deinit shows up inside a local context
When braces are mismatched, we can have a deinit inside a function, so
ensure we don't crash in validateDecl.

rdar://problem/28867782
2016-11-11 11:41:08 -08:00
Mark Lacey
18c809d1d4 Fix crash in member lookup when base type contains type variables.
We were crashing during performTypoCorrection if the base type contained
type variables.

rdar://problem/28387684
2016-11-02 21:12:47 -07:00
Rintaro Ishizaki
43003a7e14 An IDE crasher was fixed in previous commit 2016-10-19 02:22:23 +09:00
Rintaro Ishizaki
e52e043d57 [Parse] Don't use tok::unknown as a dummy token (#5171)
Use tok::NUM_TOKENS instead. tok::unknown can easily appear in source code.

For instance `skipUntil(tok::eof)` did not work as expected, because that was
`skipUntil(tok::eof, tok::unknown)` hence does stop at error tokens such as
`0xG` (invalid hex number literal).

Revert 2abc92bbb5, since that was
accidental side-effect of 45118037cc.
Forward references are not allowed actually.
2016-10-07 14:37:11 +09:00
Slava Pestov
581c99ba61 Resolve some crashers 2016-10-03 00:39:50 -04:00
Slava Pestov
f19192d498 ArchetypeBuilder: Sort requirements in enumerateRequirements()
Move the sorting algorithm from construction of the canonical mangling
signature to requirement enumeration.

This also changes how same-type constraints pick representatives, using
the more canonical total order.
2016-09-06 11:51:13 -07:00
Ben Langmuir
2855634999 [codecomplete] Check for ErrorType before asking for CD->getResultType()
Fixes a crash where we try to cast ErrorType to a function type to get
the result.

rdar://problem/27763826
2016-08-23 13:14:56 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Slava Pestov
47898c5962 These tests no longer require asserts to be enabled
Review feedback from @jrose-apple.
2016-08-05 16:26:01 -07:00
Slava Pestov
522f4e4572 AST: Replace recently-added IsInOut bit with simpler check, NFC
Thanks to @lattner for the suggestion.
2016-08-05 14:27:16 -07:00
David Farler
7bfaeb57f1 [SE-0081] Warn on deprecated where clause inside angle brackets
and provide a fix-it to move it to the new location as referenced
in SE-0081.

Fix up a few stray places in the standard library that is still using
the old syntax.

Update any ./test files that aren't expecting the new warning/fix-it
in -verify mode.

While investigating what I thought was a new crash due to this new
diagnostic, I discovered two sources of quite a few compiler crashers
related to unterminated generic parameter lists, where the right
angle bracket source location was getting unconditionally set to
the current token, even though it wasn't actually a '>'.
2016-07-26 01:41:10 -07:00