Commit Graph

8 Commits

Author SHA1 Message Date
Hamish Knight
2d7500eda6 [AST] Remove ParenType
Today ParenType is used:

1. As the type of ParenExpr
2. As the payload type of an unlabeled single
   associated value enum case (and the type of
   ParenPattern).
3. As the type for an `(X)` TypeRepr

For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.

3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
2024-10-31 11:32:40 +00:00
Slava Pestov
7a16b0275b AST: Allow one-element tuple types to be constructed
These will never appear in the source language, but can arise
after substitution when the original type is a tuple type with
a pack expansion type.

Two examples:
- original type: (Int, T...), substitution T := {}
- original type: (T...), substitution T := {Int}

We need to model these correctly to maintain invariants.

Callers that previously used to rely on TupleType::get()
returning a ParenType now explicitly check for the one-element
case instead.
2022-08-23 11:12:00 -04:00
ematejska
1420b815d5 [Autodiff upstream] Upstream autodiff unittests (#30709)
* Adding @transpose attr deserialization support

* Turning on the transpose serialization test

* Adding the autodiff unittests
2020-03-30 09:14:22 -07:00
Dan Zheng
b826b3cc04 [AST] Fix bug in IndexSubset::findPrevious. (#29675)
Fix incorrect loop decrement in `IndexSubset::findPrevious`
Add unit tests.
2020-02-06 14:24:00 -08:00
Gogul Balakrishnan
68185cf59e Fix memory error in the implementation of IndexSubset. 2019-10-21 23:47:17 -07:00
Rintaro Ishizaki
dfd47a38bb [UnitTests] Temporarily disable IndexSubset testcases while investigating
rdar://problem/56338898
2019-10-18 16:32:33 -07:00
Richard Wei
c55962c97e Fix indentation in tests and remove unrelated tests. 2019-10-11 13:11:08 -07:00
Richard Wei
9765858d31 Rename to 'IndexSubset' and move it to its own file. 2019-10-11 13:07:53 -07:00