Commit Graph

20 Commits

Author SHA1 Message Date
Minhyuk Kim
7eaabe1996 Simplify unused lvalue warning wording 2021-01-15 22:14:56 +09:00
Slava Pestov
0310a701d9 AST: Remove EnableASTScope flag and force it to always be on 2020-09-04 16:15:36 -04:00
Robert Widmann
0267384e11 Fixup SourceKit and Tests
Patch up all the places that are making a syntactic judgement about the
isInvalid() bit in a ValueDecl.  They may continue to use that query,
but most guard themselves on whether the interface type has been set.
2019-10-30 15:09:14 -07:00
Robert Widmann
742f6b2102 Drastically Simplify VarDecl Validation
This is an amalgam of simplifications to the way VarDecls are checked
and assigned interface types.

First, remove TypeCheckPattern's ability to assign the interface and
contextual types for a given var decl.  Instead, replace it with the
notion of a "naming pattern".  This is the pattern that semantically
binds a given VarDecl into scope, and whose type will be used to compute
the interface type. Note that not all VarDecls have a naming pattern
because they may not be canonical.

Second, remove VarDecl's separate contextual type member, and force the
contextual type to be computed the way it always was: by mapping the
interface type into the parent decl context.

Third, introduce a catch-all diagnostic to properly handle the change in
the way that circularity checking occurs.  This is also motivated by
TypeCheckPattern not being principled about which parts of the AST it
chooses to invalidate, especially the parent pattern and naming patterns
for a given VarDecl.  Once VarDecls are invalidated along with their
parent patterns, a large amount of this diagnostic churn can disappear.
Unfortunately, if this isn't here, we will fail to catch a number of
obviously circular cases and fail to emit a diagnostic.
2019-10-14 12:06:50 -07:00
fischertony
ba1bbd028d updated missed tests 2018-04-22 20:48:24 +03:00
Rintaro Ishizaki
546aeb2336 [Parse] Remove Parser support for C-style for statement. 2017-08-04 23:27:15 +09:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Doug Gregor
861d5d33d6 [Parser] Minor location tweak to aid the scope map. 2016-10-17 22:13:52 -07:00
John McCall
3fc2291733 Add basic typo correction for unqualified lookup.
There's a lot of room for better QoI / performance here.
2016-05-20 11:04:58 -07:00
Chris Lattner
3549ec5404 [QoI] make several improvements to the unused expression diagnostics, to go
along with recent policy changes:

- For expression types that are not specifically handled, make sure to
  produce a general "unused value" warning, catching a bunch of unused
  values in the testsuite.

- For unused operator results, diagnose them as uses of the operator
  instead of "calls".

- For calls, mutter the type of the result for greater specificity.

- For initializers, mutter the type of the initialized value.

- Look through OpenExistentialExpr's so we can handle protocol member
  references propertly.

- Look through several other expressions so we handle @discardableResult
  better.
2016-05-16 23:26:07 -07:00
Trent Nadeau
0cc851568a Updated tests to use @discardableResult and _ = . 2016-05-11 22:53:38 -04:00
John McCall
bc3b47b98a Infer the return type of a closure to be () if it contains no
return statements, or a return statement with no operand.

Also, fix a special-case diagnostic about converting a return
expression to (1) only apply to converting the actual return
expression, not an arbitrary sub-expression, and (2) use the
actual operand and return types, not the drilled-down types
that caused the failure.

Swift SVN r30420
2015-07-20 21:52:18 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +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
Joe Pamer
fa692976f5 If an expression fails to type check, and there were no failures posted or constraints to mine for a reason, we can be fairly certain that the reason for the failure was a lack of contextual type data. In this case, we should post a diagnostic rather than let the failure slip through. This addresses crash suite scenarios 001, 005, 020 and 045. (rdar://problem/16712071, rdar://problem/17317691, rdar://problem/17317691)
You'll notice that emitting this diagnostic will make some already noisy closure-related errors slightly more so. This is unfortunate, but for the time-being it's better than crashing.

Swift SVN r21817
2014-09-09 23:58:59 +00:00
Joe Groff
88f2632a44 Allow trailing closures with a line break before '{'.
Swift SVN r19322
2014-06-28 05:12:48 +00:00
Dave Abrahams
b7a8fc7d4c Revert "Allow trailing closures with a line break before '{'."
This reverts r19315, which broke my build:

-- Testing: 1 tests, 1 threads --
FAIL: Swift :: Interpreter/arrays.swift (1 of 1)
******************** TEST 'Swift :: Interpreter/arrays.swift' FAILED ********************
Script:
--
rm -rf /Users/dave/build/swift/Ninja-RelWithDebInfo/swift/test/Interpreter/Output/arrays.swift.tmp && mkdir -p /Users/dave/build/swift/Ninja-RelWithDebInfo/swift/test/Interpreter/Output/arrays.swift.tmp && xcrun -sdk macosx10.10 /Users/dave/build/swift/Ninja-RelWithDebInfo/swift/bin/swift -target x86_64-apple-macosx10.9 -resource-dir '/Users/dave/build/swift/Ninja-RelWithDebInfo/swift/lib/swift' -module-cache-path /Users/dave/build/swift/Ninja-RelWithDebInfo/swift/swift-module-cache -module-cache-path /Users/dave/build/swift/Ninja-RelWithDebInfo/swift/test/Interpreter/Output/arrays.swift.tmp/clang-module-cache /Users/dave/src/s/swift/test/Interpreter/arrays.swift -o /Users/dave/build/swift/Ninja-RelWithDebInfo/swift/test/Interpreter/Output/arrays.swift.tmp/a.out &&  /Users/dave/build/swift/Ninja-RelWithDebInfo/swift/test/Interpreter/Output/arrays.swift.tmp/a.out | FileCheck /Users/dave/src/s/swift/test/Interpreter/arrays.swift
--
Exit Code: 1

Command Output (stderr):
--
/Users/dave/src/s/swift/test/Interpreter/arrays.swift:54:1: error: invalid use of '()' to call a value of non-function type '()'
println()
^

Swift SVN r19317
2014-06-28 01:51:45 +00:00
Joe Groff
0c9fc15ae1 Allow trailing closures with a line break before '{'.
Swift SVN r19315
2014-06-28 00:36:45 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Argyrios Kyrtzidis
3a1d504cff [Parser] Fix crash-on-invalid, with top-level statements and -parse-as-library.
Part of rdar://15484631

Swift SVN r10558
2013-11-19 17:55:04 +00:00