@@ -119,6 +119,28 @@ is valid. This basically corresponds to the block nesting structure:
119
119
the regions for outer block scopes are superregions of those for inner
120
120
block scopes.
121
121
122
+ ## Integral type variables
123
+
124
+ There is a third variety of type variable that we use only for
125
+ inferring the types of unsuffixed integer literals. Integral type
126
+ variables differ from general-purpose type variables in that there's
127
+ no subtyping relationship among the various integral types, so instead
128
+ of associating each variable with an upper and lower bound, we
129
+ represent the set of possible integral types it can take on with an
130
+ `int_ty_set`, which is a bitvector with one bit for each integral
131
+ type. Because intersecting these sets with each other is simpler than
132
+ merging bounds, we don't need to do so transactionally as we do for
133
+ general-purpose type variables.
134
+
135
+ We could conceivably define a subtyping relationship among integral
136
+ types based on their ranges, but we choose not to open that particular
137
+ can of worms. Our strategy is to treat integral type variables as
138
+ unknown until the typing context constrains them to a unique integral
139
+ type, at which point they take on that type. If the typing context
140
+ overconstrains the type, it's a type error; if we reach the point at
141
+ which type variables must be resolved and an integral type variable is
142
+ still underconstrained, it defaults to `int` as a last resort.
143
+
122
144
## GLB/LUB
123
145
124
146
Computing the greatest-lower-bound and least-upper-bound of two
@@ -829,7 +851,7 @@ impl unify_methods for infer_ctxt {
829
851
}
830
852
} else if nde_a. rank < nde_b. rank {
831
853
#debug[ "vars(): b has smaller rank" ] ;
832
- // b has geater rank, so a should redirect to b.
854
+ // b has greater rank, so a should redirect to b.
833
855
self . set ( vb, a_id, redirect ( b_id) ) ;
834
856
self . set_var_to_merged_bounds (
835
857
vb, b_id, a_bounds, b_bounds, nde_b. rank ) . then { ||
0 commit comments