Commit Graph

18 Commits

Author SHA1 Message Date
Alex Hoppen
e14fa7291f [CS] Don’t fail constraint generation for ErrorExpr or if type fails to resolve
Instead of failing constraint generation by returning `nullptr` for an `ErrorExpr` or returning a null type when a type fails to be resolved, return a fresh type variable. This allows the constraint solver to continue further and produce more meaningful diagnostics.

Most importantly, it allows us to produce a solution where previously constraint generation for a syntactic element had failed, which is required to type check multi-statement closures in result builders inside the constraint system.
2022-07-20 09:46:12 +02:00
Josh Soref
ebc4e60560 Spelling decl (#42550)
* spelling: adjacent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ambiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: captures

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: effectful

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: nonoverride

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ouroboros

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overridden

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: qualified

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: received

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: refinement

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 09:44:52 -07:00
Minhyuk Kim
56f4a7bb7c Add unexisting_power_operator diagnostic when using unexisting ** operator in swift 2021-03-14 21:17:16 +09:00
Hamish Knight
cc062ee2bb Fix precedencegroup and operator decl lookup
Re-implement operator and precedencegroup decl
lookup to use `namelookup::getAllImports` and
existing decl shadowing logic. This allows us to
find operator decls through `@_exported` imports,
prefer operator decls defined in the same module
over imported decls, and fixes a couple of other
subtle issues.

Because this new implementation is technically
source breaking, as we can find multiple results
where we used to only find one result, it's placed
behind the new Frontend flag
`-enable-new-operator-lookup` (with the aim of
enabling it by default when we get a new language
mode).

However the new logic will always be used if the
result is unambiguous. This means that e.g
`@_exported` operators will be instantly available
as long as there's only one candidate. If multiple
candidates are found, we fall back to the old
logic.

Resolves SR-12132.
Resolves rdar://59198796.
2020-05-18 14:33:43 -07:00
Hamish Knight
e5952ab7fe Fix a couple of invalid location diagnostics 2020-03-23 09:17:58 -07:00
Hamish Knight
f3708b29ec Add tests for operator lookup and redeclaration checking 2020-03-23 09:17:58 -07:00
Chris Lattner
7572081608 change a directory with one file in it to be one file.
Swift SVN r21048
2014-08-05 22:46:11 +00:00
Chris Lattner
3ad9c58c18 Disallow (with a nice fixit) the infix modifier on func decls, it is just validated
and ignored anyway.  It is still required on operator decls though.


Swift SVN r19978
2014-07-15 16:52:04 +00:00
Jordan Rose
10815eb5f9 s/attribute/modifier/ in a number of diagnostics.
Swift SVN r19972
2014-07-15 04:57:04 +00:00
Chris Lattner
e0b0205cd7 Remove the @assignment attribute entirely. It doesn't do anything except
enforce its own little constraints.  The type checker isn't using it for
anything, and it is just clutter.

This resolves <rdar://problem/16656024> Remove @assignment from operator implementations



Swift SVN r19960
2014-07-14 22:44:25 +00:00
Chris Lattner
540203041e implement <rdar://problem/14607026> Restrict use of '<' and '>' as prefix/postfix operator names
Swift SVN r19947
2014-07-14 21:12:42 +00:00
Chris Lattner
5f55052e89 pull operator decls into the attribute flow: have the parser attach attributes
to operator decls, and validate the attributes in the type checker.  This allows
us to reject invalid operator decls (resolving a fixme) and restores syntax coloring
of 'infix' on an operator (a regression in my last patch).



Swift SVN r19932
2014-07-14 17:03:41 +00:00
Chris Lattner
57cd2506ff Change "operator infix" to "infix operator" for consistency with the rest of the declaration
modifiers and with the func implementations of the operators.  This resolves the rest of:
<rdar://problem/17527000> change operator declarations from "operator prefix" to "prefix operator" & make operator a keyword




Swift SVN r19931
2014-07-14 16:39:10 +00:00
Chris Lattner
8991456ff2 Switch infix/postfix/prefix to be declaration modifiers instead of attributes,
eliminating the @'s from them when used on func's.  This is progress towards
<rdar://problem/17527000> change operator declarations from "operator prefix" to "prefix operator" & make operator a keyword

This also consolidates rejection of custom operator definitions into one
place and makes it consistent, and adds postfix "?" to the list of rejected
operators.

This also changes the demangler to demangle weak/inout/postfix and related things
without the @.



Swift SVN r19929
2014-07-14 15:51:49 +00:00
Chris Lattner
ac6cd1490c move operator attributes off of validateAttribute onto the nicer AttributeChecker
Swift SVN r19928
2014-07-14 15:06:34 +00:00
Jim Ingham
bc6951d288 Followup to r19830: preserve the original token so we report the
correct location for the operator error, and added a test for the
error reporting for operators in non-global scopes.


Swift SVN r19862
2014-07-11 23:12:39 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Doug Gregor
faf1c45d14 Shuffle the files in the testsuite a bit to try to reflect language structure.
There's a lot more work to do here, but start to categorize tests
along the lines of what a specification might look like, with
directories (chapters) for basic concepts, declarations, expressions,
statements, etc.


Swift SVN r9958
2013-11-05 15:12:57 +00:00