@@ -482,35 +482,35 @@ program, so it's helpful to extend a new type (namely ``TTaintType``)::
482
482
483
483
.. _type-unions :
484
484
485
- Type Unions
485
+ Type unions
486
486
***********
487
487
488
488
.. note ::
489
489
The syntax for type unions is considered experimental and is subject to change.
490
- However, they appear in the `standard QL libraries <https://github.com/github/codeql> `.
491
- The following sections should help you understand those examples
490
+ However, type unions appear in the `standard QL libraries <https://github.com/github/codeql >`__ .
491
+ The following sections should help you understand those examples.
492
492
493
493
Type unions are user-defined types that are declared with the keyword ``class ``.
494
- The syntax resembles type aliases, but with two or more type expressions on the right-hand side.
494
+ The syntax resembles :ref: ` type aliases < type-aliases >` , but with two or more type expressions on the right-hand side.
495
495
496
- Type unions are used for creating restricted versions of existing algebraic datatypes, by explicitly
497
- selecting a subset of the branches of said datatype and binding them to a new type.
498
- In addition to this, type unions of database types are also supported.
496
+ Type unions are used for creating restricted versions of an existing :ref: ` algebraic datatype < algebraic- datatypes>` , by explicitly
497
+ selecting a subset of the branches of that datatype and binding them to a new type.
498
+ Type unions of :ref: ` database types < database-types >` are also supported.
499
499
500
- Using a type union to explicitly restrict the permitted branches from an algebraic datatype
501
- can resolve spurious recursion in predicates.
500
+ You can use a type union to explicitly restrict the permitted branches from an algebraic datatype
501
+ and resolve spurious :ref: ` recursion < recursion >` in predicates.
502
502
For example, the following construction is legal::
503
503
504
504
newtype T =
505
- T1(T t) { not exists(T2orT3 s | t = s) } or
506
- T2(int x) { x = 1 or x = 2 } or
507
- T3(int x) { x = 3 or x = 4 or x = 5 }
505
+ T1(T t) { not exists(T2orT3 s | t = s) } or
506
+ T2(int x) { x = 1 or x = 2 } or
507
+ T3(int x) { x = 3 or x = 4 or x = 5 }
508
508
509
509
class T2orT3 = T2 or T3;
510
510
511
511
However, a similar implementation that restricts ``T `` in a class extension is not valid.
512
512
The class ``T2orT3 `` triggers a type test for ``T ``, which results in an illegal recursion
513
- ``T2orT3->T->T1->¬T2orT2 `` due to the reliance of ``T1 `` on ``T2orT3 ``::
513
+ ``T2orT3 -> T -> T1 -> ¬T2orT3 `` since ``T1 `` relies on ``T2orT3 ``::
514
514
515
515
class T2orT3 extends T {
516
516
T2orT3() {
0 commit comments