Commit Graph

12 Commits

Author SHA1 Message Date
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Hamish Knight
7b4c9fef02 Allow implicit last expressions for functions and closures
Gated behind the experimental feature
`ImplicitLastExprResults`.
2024-02-07 18:14:23 +00:00
Hamish Knight
e7230491d5 [test] Add a couple of locator tests for if/switch exprs 2024-02-01 12:18:46 +00:00
Hamish Knight
d9fd4c75b1 [CS] Remove isInputExpression parameter
This wasn't consistently used, and consequently
could result in some expressions getting their
parents invalidated. Instead, replace it with a
query to make sure we don't try and add an
expression we've already computed the parent info
for.
2024-01-31 20:26:20 +00:00
Hamish Knight
9b64990d24 [AST] Remove the "single expression body" bit
Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
2024-01-30 14:08:54 +00:00
Doug Gregor
ef642098f2 [Typed throws] Parsing and AST representation for typed errors
Parse typed throw specifiers as `throws(X)` in every place where there
are effects specified, and record the resulting thrown error type in
the AST except the type system. This includes:
* `FunctionTypeRepr`, for the parsed representation of types
* `AbstractFunctionDecl`, for various function-like declarations
* `ClosureExpr`, for closures
* `ArrowExpr`, for parsing of types within expression context

This also introduces some serialization logic for the thrown error
type of function-like declarations, along with an API to extract the
thrown interface type from one of those declarations, although right
now it will either be `Error` or empty.
2023-09-29 10:51:51 -07:00
Pavel Yaskevich
1691f32d84 [CSGen] Type-check capture list together with closure body
Delay constraint generation for capture list until body of
the associated closure is resolved. This means that we can
unify capture checking with that of regular pattern bindings
for multi-statement closures.
2023-03-17 15:22:38 -07:00
Hamish Knight
2976edbe20 [CS] Rename SolutionApplicationTarget -> SyntacticElementTarget 2023-03-06 20:54:06 +00:00
Pavel Yaskevich
60720f4e07 [CSGen] Captures should always be connected to their closure
Otherwise it might be possible (once references are not resolved
eagerly for example) to get a situation where closure is solved
before captures are.
2023-01-24 10:43:29 -08:00
Erik Eckstein
8dbbfabea5 AST: add debug locations for generated IntegerLiteralExprs 2023-01-02 13:52:21 +01:00
Pavel Yaskevich
15772e4a72 [CSApply] Ajust expression rewriter to handle casts without reprs
Implicit casts are allowed to provide cast type directly without
a type repr, adjust solution application logic to handle this just
like constraint generator does. Also fix a couple of places where
declaration context from constraint system was used instead
of one associated with the expression rewriter.
2022-03-23 00:18:55 -07:00
Pavel Yaskevich
37da96092c [CSGen] Don't expect implicit casts to have type reprs
Implicit casts are allowed to be constructed with a type, instead
of a type repr. Constraint generation should honor that, and fallback
to using cast type when repr is was not given.
2022-03-22 13:19:32 -07:00