Skip to content

Spec: Rewrite the type system fundamentals. #17447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/_docs/internals/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ SimpleType1 ::= id
Singleton ::= SimpleRef
| SimpleLiteral
| Singleton ‘.’ id
Singletons ::= Singleton { ‘,’ Singleton }
FunArgType ::= [`erased`] Type
| [`erased`] ‘=>’ Type PrefixOp(=>, t)
FunArgTypes ::= FunArgType { ‘,’ FunArgType }
Expand Down Expand Up @@ -357,8 +356,8 @@ ClsParam ::= {Annotation}
[{Modifier} (‘val’ | ‘var’) | ‘inline’] Param
DefParamClauses ::= DefParamClause { DefParamClause } -- and two DefTypeParamClause cannot be adjacent
DefParamClause ::= DefTypeParamClause
| DefTermParamClause
DefParamClause ::= DefTypeParamClause
| DefTermParamClause
| UsingParamClause
TypelessClauses ::= TypelessClause {TypelessClause}
TypelessClause ::= DefTermParamClause
Expand Down
3 changes: 1 addition & 2 deletions docs/_docs/reference/new-types/intersection-types-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ A & B <: B A & B <: A
In another word, `A & B` is the same type as `B & A`, in the sense that the two types
have the same values and are subtypes of each other.

If `C` is a type constructor, then `C[A] & C[B]` can be simplified using the following three rules:
If `C` is a co- or contravariant type constructor, then `C[A] & C[B]` can be simplified using the following rules:

- If `C` is covariant, `C[A] & C[B] ~> C[A & B]`
- If `C` is contravariant, `C[A] & C[B] ~> C[A | B]`
- If `C` is non-variant, emit a compile error

When `C` is covariant, `C[A & B] <: C[A] & C[B]` can be derived:

Expand Down
2 changes: 1 addition & 1 deletion docs/_spec/02-identifiers-names-and-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ In that case, the type of ´x´ is the type of the referenced entity.

A reference to a qualified (type- or term-) identifier ´e.x´ refers to the member of the type ´T´ of ´e´ which has the name ´x´ in the same namespace as the identifier.
It is an error if ´T´ is not a [value type](03-types.html#value-types).
The type of ´e.x´ is the member type of the referenced entity in ´T´.
The type of ´e.x´ is specified as a [type designator](03-types.html#type-designators).

Binding precedence implies that the way source is bundled in files affects name resolution.
In particular, imported names have higher precedence than names, defined in other files, that might otherwise be visible because they are defined in either the current package or an enclosing package.
Expand Down
Loading