Add associative map constraints and range refinement
This commit is contained in:
@@ -30,8 +30,9 @@ Ports = [...(Int & >= 1 & <= 65535)];
|
||||
[...String] & ["api", "worker"]
|
||||
```
|
||||
|
||||
要素制約は object schema にもできる。
|
||||
要素 schema の default は、配列へ制約を合成するときに各要素へ適用される。
|
||||
要素制約は object range にもできる。
|
||||
右辺だけにある default 付き field は、配列へ制約を合成した時点では abstract のまま各要素に残る。
|
||||
その配列を後から materialize した場合にだけ default が使われる。
|
||||
|
||||
```dcdl
|
||||
Services = [...{
|
||||
@@ -42,6 +43,9 @@ Services = [...{
|
||||
Services & [{ name = "api"; }]
|
||||
```
|
||||
|
||||
配列制約を concrete array に適用すると、各要素は要素 range に対して `as` と同じ規則で絞り込まれる。
|
||||
object の要素 range では左辺にしかない field がエラーになり、右辺にしかない field は abstract のまま残る。
|
||||
|
||||
要素制約のない抽象配列型は提供しない。
|
||||
旧来の `Array` primitive type は使用できず、`[...T]` の `T` は必須である。
|
||||
`[String]` は配列制約ではなく、未解決の `String` 制約を 1 要素に持つ concrete array になる。
|
||||
|
||||
Reference in New Issue
Block a user