Skip to content

Commit fcf52a2

Browse files
committed
Check actual type parameters against their bounds
1 parent a260073 commit fcf52a2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

0000-well-formed.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- Start Date: 2014-04-05
2+
- RFC PR #:
3+
- Rust Issue #:
4+
5+
# Summary
6+
7+
Check all types for well-formedness with respect to the bounds of type variables.
8+
9+
# Motivation
10+
11+
Makes type checking saner. Catches errors earlier in the development process. Matches behaviour with built-in bounds (I think).
12+
13+
# Detailed design
14+
15+
Whenever a type is used it must be checked for well-formedness. For polymorphic types we currently check only that the type exists. I would like to also check that any actual type parameters are valid. That is, given a type `T<U>` where `T` is declared as `T<X: B>`, we currently only check that `T` does in fact exist somewhere (I think we also check that the correct number of type parameters are supplied, in this case one). I would also like to check that `U` satisfies the bound `B`.
16+
17+
Work on built-in bounds is (I think) in the process of adding this behaviour for built-in bounds. I would like to apply this to user-specified bounds too.
18+
19+
I think no fewer programs can be expressed. That is, any errors we catch with this new check would have been caught later in the existing scheme, where exactly would depend on where the type was used. The only exception would be if the formal type variable was not used.
20+
21+
# Alternatives
22+
23+
Keep the status quo.
24+
25+
# Unresolved questions
26+

0 commit comments

Comments
 (0)