Skip to content

Commit 8c1c920

Browse files
committed
fix review findings
1 parent 12c211d commit 8c1c920

26 files changed

Lines changed: 113 additions & 11 deletions

File tree

documentation/linter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ Generates:
414414
#### union_partial_field_access
415415

416416
Accessing a field on a union type that does not exist in all member
417-
types is allowed but may return `null` at run-time. The linter warns
417+
types is allowed but may return `null` at run-time. The linter warns
418418
so that users are aware of this.
419419

420420
```trlc

language-reference-manual/lrm.trlc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ section "Type declarations" {
726726
types may not appear in a union type.'''
727727
}
728728

729-
Static_Semantics Union_Type_No_Field_Access {
729+
Static_Semantics Union_Type_Field_Access_Validity {
730730
text = '''A field access on a component with a union type is
731731
permitted if the field exists (by name) in at least one
732732
member type. If the field does not exist in any member
@@ -735,7 +735,7 @@ section "Type declarations" {
735735

736736
Static_Semantics Union_Type_Field_Access {
737737
text = '''When field access on a union-typed component is
738-
permitted (see Union_Type_No_Field_Access), the static
738+
permitted (see Union_Type_Field_Access_Validity), the static
739739
type of the resulting expression is the declared type of
740740
that field in the member types that contain it. This
741741
type must be identical across all members that declare
@@ -779,6 +779,17 @@ section "Type declarations" {
779779
structural equality)*.'''
780780
}
781781

782+
Static_Semantics Union_Type_Equality_Domain {
783+
text = '''An equality or inequality operator applied to a union-typed
784+
component requires the other operand to have a compatible
785+
type. An operand type T is compatible with a union type U
786+
if T is one of the member types of U, or T is a (transitive)
787+
extension of a member type of U, or one of the member types
788+
of U is a (transitive) extension of T. If no such
789+
compatibility exists between the two operands, it is a
790+
static error.'''
791+
}
792+
782793
Static_Semantics Anonymous_Arrays {
783794
text = '''A component with an array declaration introduces an
784795
anonymous array type. This means the type of
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parent == other, "union vs unrelated record is a type error"
2+
^^ union-type-equality-incompatible/test.rsl:22: error: type mismatch: [TypeA, TypeB] and TypeC do not match
3+
Processed 1 model and 1 requirement file and found 1 error
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
union-type-equality-incompatible/test.rsl:22:10: trlc error: type mismatch: [TypeA, TypeB] and TypeC do not match
2+
Processed 1 model and 1 requirement file and found 1 error
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parent == other, "union vs unrelated record is a type error"
2+
^^ union-type-equality-incompatible/test.rsl:22: error: type mismatch: [TypeA, TypeB] and TypeC do not match
3+
Processed 1 model and 1 requirement file and found 1 error
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parent == other, "union vs unrelated record is a type error"
2+
^^ union-type-equality-incompatible/test.rsl:22: error: type mismatch: [TypeA, TypeB] and TypeC do not match
3+
Processed 1 model and 1 requirement file and found 1 error
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package Test
2+
3+
type TypeA {
4+
x Integer
5+
}
6+
7+
type TypeB {
8+
x Integer
9+
}
10+
11+
// Completely unrelated type - not compatible with [TypeA, TypeB]
12+
type TypeC {
13+
x Integer
14+
}
15+
16+
type Req {
17+
parent [TypeA, TypeB]
18+
other TypeC
19+
}
20+
21+
checks Req {
22+
parent == other, "union vs unrelated record is a type error"
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package Test
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
LRM.Union_Type_Equality
2+
LRM.Union_Type_Equality_Domain
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
LRM.Union_Type_Field_Access
2-
LRM.Union_Type_No_Field_Access
2+
LRM.Union_Type_Field_Access_Validity

0 commit comments

Comments
 (0)