File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -333,6 +333,24 @@ impl<'a> Printer<'a> {
333
333
}
334
334
}
335
335
336
+ /// In the AST, type variables are represented by their IDs, not their names.
337
+ /// This means that when we are printing a type variable, we either need to
338
+ /// find its name that was given by the programmer, or generate a new one.
339
+ /// Type variable names are local to functions, meaning there can be one
340
+ /// named `a` in one function, and a different one named `a` in another
341
+ /// function. However, there can't be two named `a` in the same function.
342
+ ///
343
+ /// By default, the printer avoids duplicating type variable names entirely.
344
+ /// This is because we don't have easy access to information about which type
345
+ /// variables belong to this function. In order to ensure no accidental,
346
+ /// collisions, we treat all type variables from the module as in scope, even
347
+ /// though this isn't the case.
348
+ ///
349
+ /// When sufficient information is present to ensure type variables are not
350
+ /// duplicated, `new_without_type_variables` can be used, in combination with
351
+ /// `register_type_variables` in order to precisely control which variables
352
+ /// are in scope.
353
+ ///
336
354
pub fn new_without_type_variables ( names : & ' a Names ) -> Self {
337
355
Printer {
338
356
names,
You can’t perform that action at this time.
0 commit comments