edict-lang 1.22.1 → 1.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/ast/nodes.d.ts +2 -2
- package/dist/ast/nodes.d.ts.map +1 -1
- package/dist/ast/nodes.js +1 -0
- package/dist/ast/nodes.js.map +1 -1
- package/dist/ast/type-constants.d.ts +6 -0
- package/dist/ast/type-constants.d.ts.map +1 -1
- package/dist/ast/type-constants.js +7 -0
- package/dist/ast/type-constants.js.map +1 -1
- package/dist/ast/types.d.ts +11 -1
- package/dist/ast/types.d.ts.map +1 -1
- package/dist/browser-full.bundle.js +247 -48
- package/dist/browser-full.bundle.js.map +3 -3
- package/dist/browser.bundle.js +247 -48
- package/dist/browser.bundle.js.map +3 -3
- package/dist/builtins/domains/array.js +27 -27
- package/dist/builtins/domains/array.js.map +1 -1
- package/dist/builtins/domains/option.js +5 -5
- package/dist/builtins/domains/option.js.map +1 -1
- package/dist/builtins/domains/result.js +7 -7
- package/dist/builtins/domains/result.js.map +1 -1
- package/dist/checker/check.d.ts.map +1 -1
- package/dist/checker/check.js +30 -2
- package/dist/checker/check.js.map +1 -1
- package/dist/checker/types-equal.d.ts.map +1 -1
- package/dist/checker/types-equal.js +4 -0
- package/dist/checker/types-equal.js.map +1 -1
- package/dist/checker/unify.d.ts +23 -0
- package/dist/checker/unify.d.ts.map +1 -0
- package/dist/checker/unify.js +126 -0
- package/dist/checker/unify.js.map +1 -0
- package/dist/edict-quickjs-check.js +247 -48
- package/dist/edict-quickjs-full.js +247 -48
- package/dist/errors/structured-errors.d.ts +1 -0
- package/dist/errors/structured-errors.d.ts.map +1 -1
- package/dist/errors/structured-errors.js +1 -1
- package/dist/errors/structured-errors.js.map +1 -1
- package/dist/lint/lint.js +24 -2
- package/dist/lint/lint.js.map +1 -1
- package/package.json +6 -5
- package/schema/edict-fragment.schema.json +34 -1
- package/schema/edict.schema.json +34 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// edict-lang v1.
|
|
1
|
+
// edict-lang v1.23.2 — browser-full bundle (phases 1-5, compile, execute, Z3 contracts)
|
|
2
2
|
// https://github.com/Sowiedu/Edict
|
|
3
3
|
|
|
4
4
|
var __create = Object.create;
|
|
@@ -7817,7 +7817,7 @@ function unknownNodeKind(path, received, validKinds, suggestion) {
|
|
|
7817
7817
|
return result;
|
|
7818
7818
|
}
|
|
7819
7819
|
function missingField(path, nodeId, field, expectedFormat, suggestion) {
|
|
7820
|
-
const result = { error: "missing_field", path, nodeId, field, expectedFormat };
|
|
7820
|
+
const result = { error: "missing_field", path, nodeId, field, expectedFormat, hint: "use edict_explain for repair context" };
|
|
7821
7821
|
if (suggestion)
|
|
7822
7822
|
result.suggestion = suggestion;
|
|
7823
7823
|
return result;
|
|
@@ -8286,6 +8286,9 @@ var edict_schema_default = {
|
|
|
8286
8286
|
},
|
|
8287
8287
|
{
|
|
8288
8288
|
$ref: "#/definitions/FreshnessType"
|
|
8289
|
+
},
|
|
8290
|
+
{
|
|
8291
|
+
$ref: "#/definitions/TypeVarType"
|
|
8289
8292
|
}
|
|
8290
8293
|
]
|
|
8291
8294
|
},
|
|
@@ -8383,6 +8386,9 @@ var edict_schema_default = {
|
|
|
8383
8386
|
},
|
|
8384
8387
|
{
|
|
8385
8388
|
$ref: "#/definitions/FreshnessType"
|
|
8389
|
+
},
|
|
8390
|
+
{
|
|
8391
|
+
$ref: "#/definitions/TypeVarType"
|
|
8386
8392
|
}
|
|
8387
8393
|
]
|
|
8388
8394
|
}
|
|
@@ -8475,6 +8481,9 @@ var edict_schema_default = {
|
|
|
8475
8481
|
},
|
|
8476
8482
|
{
|
|
8477
8483
|
$ref: "#/definitions/FreshnessType"
|
|
8484
|
+
},
|
|
8485
|
+
{
|
|
8486
|
+
$ref: "#/definitions/TypeVarType"
|
|
8478
8487
|
}
|
|
8479
8488
|
],
|
|
8480
8489
|
properties: {
|
|
@@ -8493,7 +8502,8 @@ var edict_schema_default = {
|
|
|
8493
8502
|
"confidence",
|
|
8494
8503
|
"provenance",
|
|
8495
8504
|
"capability",
|
|
8496
|
-
"fresh"
|
|
8505
|
+
"fresh",
|
|
8506
|
+
"type_var"
|
|
8497
8507
|
]
|
|
8498
8508
|
}
|
|
8499
8509
|
}
|
|
@@ -8735,6 +8745,9 @@ var edict_schema_default = {
|
|
|
8735
8745
|
},
|
|
8736
8746
|
{
|
|
8737
8747
|
$ref: "#/definitions/FreshnessType"
|
|
8748
|
+
},
|
|
8749
|
+
{
|
|
8750
|
+
$ref: "#/definitions/TypeVarType"
|
|
8738
8751
|
}
|
|
8739
8752
|
]
|
|
8740
8753
|
}
|
|
@@ -8934,6 +8947,23 @@ var edict_schema_default = {
|
|
|
8934
8947
|
"maxAge"
|
|
8935
8948
|
]
|
|
8936
8949
|
},
|
|
8950
|
+
TypeVarType: {
|
|
8951
|
+
description: "Type variable \u2014 placeholder for a concrete type, resolved at call sites.\nUsed in polymorphic builtin signatures (e.g., array_get: Array<T> \u2192 T).\nCompile-time only \u2014 erased during type checking (unified with concrete types).\nNever appears in user-written ASTs; only in builtin type definitions.",
|
|
8952
|
+
type: "object",
|
|
8953
|
+
properties: {
|
|
8954
|
+
kind: {
|
|
8955
|
+
type: "string",
|
|
8956
|
+
const: "type_var"
|
|
8957
|
+
},
|
|
8958
|
+
name: {
|
|
8959
|
+
type: "string"
|
|
8960
|
+
}
|
|
8961
|
+
},
|
|
8962
|
+
required: [
|
|
8963
|
+
"kind",
|
|
8964
|
+
"name"
|
|
8965
|
+
]
|
|
8966
|
+
},
|
|
8937
8967
|
Identifier: {
|
|
8938
8968
|
type: "object",
|
|
8939
8969
|
properties: {
|
|
@@ -9146,6 +9176,9 @@ var edict_schema_default = {
|
|
|
9146
9176
|
},
|
|
9147
9177
|
{
|
|
9148
9178
|
$ref: "#/definitions/FreshnessType"
|
|
9179
|
+
},
|
|
9180
|
+
{
|
|
9181
|
+
$ref: "#/definitions/TypeVarType"
|
|
9149
9182
|
}
|
|
9150
9183
|
]
|
|
9151
9184
|
},
|
|
@@ -10518,6 +10551,9 @@ var edict_fragment_schema_default = {
|
|
|
10518
10551
|
},
|
|
10519
10552
|
{
|
|
10520
10553
|
$ref: "#/definitions/FreshnessType"
|
|
10554
|
+
},
|
|
10555
|
+
{
|
|
10556
|
+
$ref: "#/definitions/TypeVarType"
|
|
10521
10557
|
}
|
|
10522
10558
|
]
|
|
10523
10559
|
},
|
|
@@ -10615,6 +10651,9 @@ var edict_fragment_schema_default = {
|
|
|
10615
10651
|
},
|
|
10616
10652
|
{
|
|
10617
10653
|
$ref: "#/definitions/FreshnessType"
|
|
10654
|
+
},
|
|
10655
|
+
{
|
|
10656
|
+
$ref: "#/definitions/TypeVarType"
|
|
10618
10657
|
}
|
|
10619
10658
|
]
|
|
10620
10659
|
}
|
|
@@ -10707,6 +10746,9 @@ var edict_fragment_schema_default = {
|
|
|
10707
10746
|
},
|
|
10708
10747
|
{
|
|
10709
10748
|
$ref: "#/definitions/FreshnessType"
|
|
10749
|
+
},
|
|
10750
|
+
{
|
|
10751
|
+
$ref: "#/definitions/TypeVarType"
|
|
10710
10752
|
}
|
|
10711
10753
|
],
|
|
10712
10754
|
properties: {
|
|
@@ -10725,7 +10767,8 @@ var edict_fragment_schema_default = {
|
|
|
10725
10767
|
"confidence",
|
|
10726
10768
|
"provenance",
|
|
10727
10769
|
"capability",
|
|
10728
|
-
"fresh"
|
|
10770
|
+
"fresh",
|
|
10771
|
+
"type_var"
|
|
10729
10772
|
]
|
|
10730
10773
|
}
|
|
10731
10774
|
}
|
|
@@ -10967,6 +11010,9 @@ var edict_fragment_schema_default = {
|
|
|
10967
11010
|
},
|
|
10968
11011
|
{
|
|
10969
11012
|
$ref: "#/definitions/FreshnessType"
|
|
11013
|
+
},
|
|
11014
|
+
{
|
|
11015
|
+
$ref: "#/definitions/TypeVarType"
|
|
10970
11016
|
}
|
|
10971
11017
|
]
|
|
10972
11018
|
}
|
|
@@ -11166,6 +11212,23 @@ var edict_fragment_schema_default = {
|
|
|
11166
11212
|
"maxAge"
|
|
11167
11213
|
]
|
|
11168
11214
|
},
|
|
11215
|
+
TypeVarType: {
|
|
11216
|
+
description: "Type variable \u2014 placeholder for a concrete type, resolved at call sites.\nUsed in polymorphic builtin signatures (e.g., array_get: Array<T> \u2192 T).\nCompile-time only \u2014 erased during type checking (unified with concrete types).\nNever appears in user-written ASTs; only in builtin type definitions.",
|
|
11217
|
+
type: "object",
|
|
11218
|
+
properties: {
|
|
11219
|
+
kind: {
|
|
11220
|
+
type: "string",
|
|
11221
|
+
const: "type_var"
|
|
11222
|
+
},
|
|
11223
|
+
name: {
|
|
11224
|
+
type: "string"
|
|
11225
|
+
}
|
|
11226
|
+
},
|
|
11227
|
+
required: [
|
|
11228
|
+
"kind",
|
|
11229
|
+
"name"
|
|
11230
|
+
]
|
|
11231
|
+
},
|
|
11169
11232
|
Identifier: {
|
|
11170
11233
|
type: "object",
|
|
11171
11234
|
properties: {
|
|
@@ -11378,6 +11441,9 @@ var edict_fragment_schema_default = {
|
|
|
11378
11441
|
},
|
|
11379
11442
|
{
|
|
11380
11443
|
$ref: "#/definitions/FreshnessType"
|
|
11444
|
+
},
|
|
11445
|
+
{
|
|
11446
|
+
$ref: "#/definitions/TypeVarType"
|
|
11381
11447
|
}
|
|
11382
11448
|
]
|
|
11383
11449
|
},
|
|
@@ -13494,10 +13560,13 @@ var FLOAT_TYPE = { kind: "basic", name: "Float" };
|
|
|
13494
13560
|
var STRING_TYPE = { kind: "basic", name: "String" };
|
|
13495
13561
|
var BOOL_TYPE = { kind: "basic", name: "Bool" };
|
|
13496
13562
|
var UNKNOWN_TYPE = { kind: "named", name: "unknown" };
|
|
13497
|
-
var ARRAY_INT_TYPE = { kind: "array", element: INT_TYPE };
|
|
13498
|
-
var OPTION_INT_TYPE = { kind: "option", inner: INT_TYPE };
|
|
13499
|
-
var RESULT_INT_TYPE = { kind: "result", ok: INT_TYPE, err: INT_TYPE };
|
|
13500
13563
|
var RESULT_STRING_TYPE = { kind: "result", ok: STRING_TYPE, err: STRING_TYPE };
|
|
13564
|
+
var T_TYPE = { kind: "type_var", name: "T" };
|
|
13565
|
+
var E_TYPE = { kind: "type_var", name: "E" };
|
|
13566
|
+
var U_TYPE = { kind: "type_var", name: "U" };
|
|
13567
|
+
var ARRAY_T_TYPE = { kind: "array", element: T_TYPE };
|
|
13568
|
+
var OPTION_T_TYPE = { kind: "option", inner: T_TYPE };
|
|
13569
|
+
var RESULT_T_E_TYPE = { kind: "result", ok: T_TYPE, err: E_TYPE };
|
|
13501
13570
|
|
|
13502
13571
|
// dist/builtins/host-helpers.js
|
|
13503
13572
|
var EdictOomError = class extends Error {
|
|
@@ -15262,7 +15331,7 @@ function generateArraySort(mod) {
|
|
|
15262
15331
|
var HOST_ARRAY_BUILTINS = [
|
|
15263
15332
|
{
|
|
15264
15333
|
name: "array_length",
|
|
15265
|
-
type: { kind: "fn_type", params: [
|
|
15334
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE], effects: ["pure"], returnType: INT_TYPE },
|
|
15266
15335
|
impl: {
|
|
15267
15336
|
kind: "host",
|
|
15268
15337
|
factory: (ctx) => (arrPtr) => {
|
|
@@ -15272,7 +15341,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15272
15341
|
},
|
|
15273
15342
|
{
|
|
15274
15343
|
name: "array_get",
|
|
15275
|
-
type: { kind: "fn_type", params: [
|
|
15344
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE, INT_TYPE], effects: ["pure"], returnType: T_TYPE },
|
|
15276
15345
|
impl: {
|
|
15277
15346
|
kind: "host",
|
|
15278
15347
|
factory: (ctx) => (arrPtr, index) => {
|
|
@@ -15286,7 +15355,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15286
15355
|
},
|
|
15287
15356
|
{
|
|
15288
15357
|
name: "array_set",
|
|
15289
|
-
type: { kind: "fn_type", params: [
|
|
15358
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE, INT_TYPE, T_TYPE], effects: ["pure"], returnType: ARRAY_T_TYPE },
|
|
15290
15359
|
impl: {
|
|
15291
15360
|
kind: "host",
|
|
15292
15361
|
factory: (ctx) => (arrPtr, index, value) => {
|
|
@@ -15302,7 +15371,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15302
15371
|
},
|
|
15303
15372
|
{
|
|
15304
15373
|
name: "array_push",
|
|
15305
|
-
type: { kind: "fn_type", params: [
|
|
15374
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE, T_TYPE], effects: ["pure"], returnType: ARRAY_T_TYPE },
|
|
15306
15375
|
impl: {
|
|
15307
15376
|
kind: "host",
|
|
15308
15377
|
factory: (ctx) => (arrPtr, value) => {
|
|
@@ -15319,7 +15388,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15319
15388
|
},
|
|
15320
15389
|
{
|
|
15321
15390
|
name: "array_pop",
|
|
15322
|
-
type: { kind: "fn_type", params: [
|
|
15391
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE], effects: ["pure"], returnType: ARRAY_T_TYPE },
|
|
15323
15392
|
impl: {
|
|
15324
15393
|
kind: "host",
|
|
15325
15394
|
factory: (ctx) => (arrPtr) => {
|
|
@@ -15337,7 +15406,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15337
15406
|
},
|
|
15338
15407
|
{
|
|
15339
15408
|
name: "array_concat",
|
|
15340
|
-
type: { kind: "fn_type", params: [
|
|
15409
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE, ARRAY_T_TYPE], effects: ["pure"], returnType: ARRAY_T_TYPE },
|
|
15341
15410
|
impl: {
|
|
15342
15411
|
kind: "host",
|
|
15343
15412
|
factory: (ctx) => (aPtr, bPtr) => {
|
|
@@ -15357,7 +15426,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15357
15426
|
},
|
|
15358
15427
|
{
|
|
15359
15428
|
name: "array_slice",
|
|
15360
|
-
type: { kind: "fn_type", params: [
|
|
15429
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE, INT_TYPE, INT_TYPE], effects: ["pure"], returnType: ARRAY_T_TYPE },
|
|
15361
15430
|
impl: {
|
|
15362
15431
|
kind: "host",
|
|
15363
15432
|
factory: (ctx) => (arrPtr, start, end) => {
|
|
@@ -15375,7 +15444,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15375
15444
|
},
|
|
15376
15445
|
{
|
|
15377
15446
|
name: "array_isEmpty",
|
|
15378
|
-
type: { kind: "fn_type", params: [
|
|
15447
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE], effects: ["pure"], returnType: BOOL_TYPE },
|
|
15379
15448
|
impl: {
|
|
15380
15449
|
kind: "host",
|
|
15381
15450
|
factory: (ctx) => (arrPtr) => {
|
|
@@ -15385,7 +15454,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15385
15454
|
},
|
|
15386
15455
|
{
|
|
15387
15456
|
name: "array_contains",
|
|
15388
|
-
type: { kind: "fn_type", params: [
|
|
15457
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE, T_TYPE], effects: ["pure"], returnType: BOOL_TYPE },
|
|
15389
15458
|
impl: {
|
|
15390
15459
|
kind: "host",
|
|
15391
15460
|
factory: (ctx) => (arrPtr, value) => {
|
|
@@ -15401,7 +15470,7 @@ var HOST_ARRAY_BUILTINS = [
|
|
|
15401
15470
|
},
|
|
15402
15471
|
{
|
|
15403
15472
|
name: "array_reverse",
|
|
15404
|
-
type: { kind: "fn_type", params: [
|
|
15473
|
+
type: { kind: "fn_type", params: [ARRAY_T_TYPE], effects: ["pure"], returnType: ARRAY_T_TYPE },
|
|
15405
15474
|
impl: {
|
|
15406
15475
|
kind: "host",
|
|
15407
15476
|
factory: (ctx) => (arrPtr) => {
|
|
@@ -15422,11 +15491,11 @@ var WASM_ARRAY_BUILTINS = [
|
|
|
15422
15491
|
type: {
|
|
15423
15492
|
kind: "fn_type",
|
|
15424
15493
|
params: [
|
|
15425
|
-
|
|
15426
|
-
{ kind: "fn_type", params: [
|
|
15494
|
+
ARRAY_T_TYPE,
|
|
15495
|
+
{ kind: "fn_type", params: [T_TYPE], effects: [], returnType: U_TYPE }
|
|
15427
15496
|
],
|
|
15428
15497
|
effects: ["pure"],
|
|
15429
|
-
returnType:
|
|
15498
|
+
returnType: { kind: "array", element: U_TYPE }
|
|
15430
15499
|
},
|
|
15431
15500
|
impl: { kind: "wasm", generator: generateArrayMap }
|
|
15432
15501
|
},
|
|
@@ -15435,11 +15504,11 @@ var WASM_ARRAY_BUILTINS = [
|
|
|
15435
15504
|
type: {
|
|
15436
15505
|
kind: "fn_type",
|
|
15437
15506
|
params: [
|
|
15438
|
-
|
|
15439
|
-
{ kind: "fn_type", params: [
|
|
15507
|
+
ARRAY_T_TYPE,
|
|
15508
|
+
{ kind: "fn_type", params: [T_TYPE], effects: [], returnType: BOOL_TYPE }
|
|
15440
15509
|
],
|
|
15441
15510
|
effects: ["pure"],
|
|
15442
|
-
returnType:
|
|
15511
|
+
returnType: ARRAY_T_TYPE
|
|
15443
15512
|
},
|
|
15444
15513
|
impl: { kind: "wasm", generator: generateArrayFilter }
|
|
15445
15514
|
},
|
|
@@ -15448,12 +15517,12 @@ var WASM_ARRAY_BUILTINS = [
|
|
|
15448
15517
|
type: {
|
|
15449
15518
|
kind: "fn_type",
|
|
15450
15519
|
params: [
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
{ kind: "fn_type", params: [
|
|
15520
|
+
ARRAY_T_TYPE,
|
|
15521
|
+
U_TYPE,
|
|
15522
|
+
{ kind: "fn_type", params: [U_TYPE, T_TYPE], effects: [], returnType: U_TYPE }
|
|
15454
15523
|
],
|
|
15455
15524
|
effects: ["pure"],
|
|
15456
|
-
returnType:
|
|
15525
|
+
returnType: U_TYPE
|
|
15457
15526
|
},
|
|
15458
15527
|
impl: { kind: "wasm", generator: generateArrayReduce }
|
|
15459
15528
|
},
|
|
@@ -15462,11 +15531,11 @@ var WASM_ARRAY_BUILTINS = [
|
|
|
15462
15531
|
type: {
|
|
15463
15532
|
kind: "fn_type",
|
|
15464
15533
|
params: [
|
|
15465
|
-
|
|
15466
|
-
{ kind: "fn_type", params: [
|
|
15534
|
+
ARRAY_T_TYPE,
|
|
15535
|
+
{ kind: "fn_type", params: [T_TYPE], effects: [], returnType: BOOL_TYPE }
|
|
15467
15536
|
],
|
|
15468
15537
|
effects: ["pure"],
|
|
15469
|
-
returnType:
|
|
15538
|
+
returnType: OPTION_T_TYPE
|
|
15470
15539
|
},
|
|
15471
15540
|
impl: { kind: "wasm", generator: generateArrayFind }
|
|
15472
15541
|
},
|
|
@@ -15475,11 +15544,11 @@ var WASM_ARRAY_BUILTINS = [
|
|
|
15475
15544
|
type: {
|
|
15476
15545
|
kind: "fn_type",
|
|
15477
15546
|
params: [
|
|
15478
|
-
|
|
15479
|
-
{ kind: "fn_type", params: [
|
|
15547
|
+
ARRAY_T_TYPE,
|
|
15548
|
+
{ kind: "fn_type", params: [T_TYPE, T_TYPE], effects: [], returnType: INT_TYPE }
|
|
15480
15549
|
],
|
|
15481
15550
|
effects: ["pure"],
|
|
15482
|
-
returnType:
|
|
15551
|
+
returnType: ARRAY_T_TYPE
|
|
15483
15552
|
},
|
|
15484
15553
|
impl: { kind: "wasm", generator: generateArraySort }
|
|
15485
15554
|
}
|
|
@@ -15490,7 +15559,7 @@ var ARRAY_BUILTINS = [...HOST_ARRAY_BUILTINS, ...WASM_ARRAY_BUILTINS];
|
|
|
15490
15559
|
var OPTION_BUILTINS = [
|
|
15491
15560
|
{
|
|
15492
15561
|
name: "isSome",
|
|
15493
|
-
type: { kind: "fn_type", params: [
|
|
15562
|
+
type: { kind: "fn_type", params: [OPTION_T_TYPE], effects: ["pure"], returnType: BOOL_TYPE },
|
|
15494
15563
|
impl: {
|
|
15495
15564
|
kind: "host",
|
|
15496
15565
|
factory: (ctx) => (ptr) => {
|
|
@@ -15500,7 +15569,7 @@ var OPTION_BUILTINS = [
|
|
|
15500
15569
|
},
|
|
15501
15570
|
{
|
|
15502
15571
|
name: "isNone",
|
|
15503
|
-
type: { kind: "fn_type", params: [
|
|
15572
|
+
type: { kind: "fn_type", params: [OPTION_T_TYPE], effects: ["pure"], returnType: BOOL_TYPE },
|
|
15504
15573
|
impl: {
|
|
15505
15574
|
kind: "host",
|
|
15506
15575
|
factory: (ctx) => (ptr) => {
|
|
@@ -15510,7 +15579,7 @@ var OPTION_BUILTINS = [
|
|
|
15510
15579
|
},
|
|
15511
15580
|
{
|
|
15512
15581
|
name: "unwrap",
|
|
15513
|
-
type: { kind: "fn_type", params: [
|
|
15582
|
+
type: { kind: "fn_type", params: [OPTION_T_TYPE], effects: ["fails"], returnType: T_TYPE },
|
|
15514
15583
|
impl: {
|
|
15515
15584
|
kind: "host",
|
|
15516
15585
|
factory: (ctx) => (ptr) => {
|
|
@@ -15524,7 +15593,7 @@ var OPTION_BUILTINS = [
|
|
|
15524
15593
|
},
|
|
15525
15594
|
{
|
|
15526
15595
|
name: "unwrapOr",
|
|
15527
|
-
type: { kind: "fn_type", params: [
|
|
15596
|
+
type: { kind: "fn_type", params: [OPTION_T_TYPE, T_TYPE], effects: ["pure"], returnType: T_TYPE },
|
|
15528
15597
|
impl: {
|
|
15529
15598
|
kind: "host",
|
|
15530
15599
|
factory: (ctx) => (ptr, defaultVal) => {
|
|
@@ -15542,7 +15611,7 @@ var OPTION_BUILTINS = [
|
|
|
15542
15611
|
var RESULT_BUILTINS = [
|
|
15543
15612
|
{
|
|
15544
15613
|
name: "isOk",
|
|
15545
|
-
type: { kind: "fn_type", params: [
|
|
15614
|
+
type: { kind: "fn_type", params: [RESULT_T_E_TYPE], effects: ["pure"], returnType: BOOL_TYPE },
|
|
15546
15615
|
impl: {
|
|
15547
15616
|
kind: "host",
|
|
15548
15617
|
factory: (ctx) => (ptr) => {
|
|
@@ -15552,7 +15621,7 @@ var RESULT_BUILTINS = [
|
|
|
15552
15621
|
},
|
|
15553
15622
|
{
|
|
15554
15623
|
name: "isErr",
|
|
15555
|
-
type: { kind: "fn_type", params: [
|
|
15624
|
+
type: { kind: "fn_type", params: [RESULT_T_E_TYPE], effects: ["pure"], returnType: BOOL_TYPE },
|
|
15556
15625
|
impl: {
|
|
15557
15626
|
kind: "host",
|
|
15558
15627
|
factory: (ctx) => (ptr) => {
|
|
@@ -15562,7 +15631,7 @@ var RESULT_BUILTINS = [
|
|
|
15562
15631
|
},
|
|
15563
15632
|
{
|
|
15564
15633
|
name: "unwrapOk",
|
|
15565
|
-
type: { kind: "fn_type", params: [
|
|
15634
|
+
type: { kind: "fn_type", params: [RESULT_T_E_TYPE], effects: ["fails"], returnType: T_TYPE },
|
|
15566
15635
|
impl: {
|
|
15567
15636
|
kind: "host",
|
|
15568
15637
|
factory: (ctx) => (ptr) => {
|
|
@@ -15576,7 +15645,7 @@ var RESULT_BUILTINS = [
|
|
|
15576
15645
|
},
|
|
15577
15646
|
{
|
|
15578
15647
|
name: "unwrapErr",
|
|
15579
|
-
type: { kind: "fn_type", params: [
|
|
15648
|
+
type: { kind: "fn_type", params: [RESULT_T_E_TYPE], effects: ["fails"], returnType: E_TYPE },
|
|
15580
15649
|
impl: {
|
|
15581
15650
|
kind: "host",
|
|
15582
15651
|
factory: (ctx) => (ptr) => {
|
|
@@ -15590,7 +15659,7 @@ var RESULT_BUILTINS = [
|
|
|
15590
15659
|
},
|
|
15591
15660
|
{
|
|
15592
15661
|
name: "unwrapOkOr",
|
|
15593
|
-
type: { kind: "fn_type", params: [
|
|
15662
|
+
type: { kind: "fn_type", params: [RESULT_T_E_TYPE, T_TYPE], effects: ["pure"], returnType: T_TYPE },
|
|
15594
15663
|
impl: {
|
|
15595
15664
|
kind: "host",
|
|
15596
15665
|
factory: (ctx) => (ptr, defaultVal) => {
|
|
@@ -15604,7 +15673,7 @@ var RESULT_BUILTINS = [
|
|
|
15604
15673
|
},
|
|
15605
15674
|
{
|
|
15606
15675
|
name: "unwrapErrOr",
|
|
15607
|
-
type: { kind: "fn_type", params: [
|
|
15676
|
+
type: { kind: "fn_type", params: [RESULT_T_E_TYPE, E_TYPE], effects: ["pure"], returnType: E_TYPE },
|
|
15608
15677
|
impl: {
|
|
15609
15678
|
kind: "host",
|
|
15610
15679
|
factory: (ctx) => (ptr, defaultVal) => {
|
|
@@ -16565,7 +16634,8 @@ var VALID_TYPE_KINDS = [
|
|
|
16565
16634
|
"confidence",
|
|
16566
16635
|
"provenance",
|
|
16567
16636
|
"capability",
|
|
16568
|
-
"fresh"
|
|
16637
|
+
"fresh",
|
|
16638
|
+
"type_var"
|
|
16569
16639
|
];
|
|
16570
16640
|
var VALID_PATTERN_KINDS = [
|
|
16571
16641
|
"literal_pattern",
|
|
@@ -16769,6 +16839,8 @@ function typesEqual(a, b, env) {
|
|
|
16769
16839
|
const rb = resolveType(b, env);
|
|
16770
16840
|
if (isUnknown(ra) || isUnknown(rb))
|
|
16771
16841
|
return true;
|
|
16842
|
+
if (ra.kind === "type_var" || rb.kind === "type_var")
|
|
16843
|
+
return true;
|
|
16772
16844
|
if (ra.kind !== rb.kind)
|
|
16773
16845
|
return false;
|
|
16774
16846
|
switch (ra.kind) {
|
|
@@ -16840,6 +16912,103 @@ function isUnknown(type) {
|
|
|
16840
16912
|
return type.kind === "named" && type.name === "unknown";
|
|
16841
16913
|
}
|
|
16842
16914
|
|
|
16915
|
+
// dist/checker/unify.js
|
|
16916
|
+
function unifyTypeVars(paramTypes, argTypes) {
|
|
16917
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
16918
|
+
const count = Math.min(paramTypes.length, argTypes.length);
|
|
16919
|
+
for (let i = 0; i < count; i++) {
|
|
16920
|
+
unifyOne(paramTypes[i], argTypes[i], bindings);
|
|
16921
|
+
}
|
|
16922
|
+
return bindings;
|
|
16923
|
+
}
|
|
16924
|
+
function unifyOne(paramType, argType, bindings) {
|
|
16925
|
+
if (paramType.kind === "type_var") {
|
|
16926
|
+
if (!bindings.has(paramType.name)) {
|
|
16927
|
+
bindings.set(paramType.name, argType);
|
|
16928
|
+
}
|
|
16929
|
+
return;
|
|
16930
|
+
}
|
|
16931
|
+
if (paramType.kind === "array" && argType.kind === "array") {
|
|
16932
|
+
unifyOne(paramType.element, argType.element, bindings);
|
|
16933
|
+
} else if (paramType.kind === "option" && argType.kind === "option") {
|
|
16934
|
+
unifyOne(paramType.inner, argType.inner, bindings);
|
|
16935
|
+
} else if (paramType.kind === "result" && argType.kind === "result") {
|
|
16936
|
+
unifyOne(paramType.ok, argType.ok, bindings);
|
|
16937
|
+
unifyOne(paramType.err, argType.err, bindings);
|
|
16938
|
+
} else if (paramType.kind === "fn_type" && argType.kind === "fn_type") {
|
|
16939
|
+
const count = Math.min(paramType.params.length, argType.params.length);
|
|
16940
|
+
for (let i = 0; i < count; i++) {
|
|
16941
|
+
unifyOne(paramType.params[i], argType.params[i], bindings);
|
|
16942
|
+
}
|
|
16943
|
+
unifyOne(paramType.returnType, argType.returnType, bindings);
|
|
16944
|
+
} else if (paramType.kind === "tuple" && argType.kind === "tuple") {
|
|
16945
|
+
const count = Math.min(paramType.elements.length, argType.elements.length);
|
|
16946
|
+
for (let i = 0; i < count; i++) {
|
|
16947
|
+
unifyOne(paramType.elements[i], argType.elements[i], bindings);
|
|
16948
|
+
}
|
|
16949
|
+
}
|
|
16950
|
+
}
|
|
16951
|
+
function substituteTypeVars(type, bindings) {
|
|
16952
|
+
if (bindings.size === 0)
|
|
16953
|
+
return type;
|
|
16954
|
+
switch (type.kind) {
|
|
16955
|
+
case "type_var": {
|
|
16956
|
+
const bound = bindings.get(type.name);
|
|
16957
|
+
return bound ?? type;
|
|
16958
|
+
}
|
|
16959
|
+
case "array":
|
|
16960
|
+
return { kind: "array", element: substituteTypeVars(type.element, bindings) };
|
|
16961
|
+
case "option":
|
|
16962
|
+
return { kind: "option", inner: substituteTypeVars(type.inner, bindings) };
|
|
16963
|
+
case "result":
|
|
16964
|
+
return {
|
|
16965
|
+
kind: "result",
|
|
16966
|
+
ok: substituteTypeVars(type.ok, bindings),
|
|
16967
|
+
err: substituteTypeVars(type.err, bindings)
|
|
16968
|
+
};
|
|
16969
|
+
case "fn_type":
|
|
16970
|
+
return {
|
|
16971
|
+
kind: "fn_type",
|
|
16972
|
+
params: type.params.map((p) => substituteTypeVars(p, bindings)),
|
|
16973
|
+
effects: type.effects,
|
|
16974
|
+
returnType: substituteTypeVars(type.returnType, bindings)
|
|
16975
|
+
};
|
|
16976
|
+
case "tuple":
|
|
16977
|
+
return {
|
|
16978
|
+
kind: "tuple",
|
|
16979
|
+
elements: type.elements.map((e) => substituteTypeVars(e, bindings))
|
|
16980
|
+
};
|
|
16981
|
+
// Leaf types — no type_var inside
|
|
16982
|
+
case "basic":
|
|
16983
|
+
case "named":
|
|
16984
|
+
case "unit_type":
|
|
16985
|
+
case "confidence":
|
|
16986
|
+
case "provenance":
|
|
16987
|
+
case "capability":
|
|
16988
|
+
case "fresh":
|
|
16989
|
+
case "refined":
|
|
16990
|
+
return type;
|
|
16991
|
+
}
|
|
16992
|
+
}
|
|
16993
|
+
function containsTypeVars(type) {
|
|
16994
|
+
switch (type.kind) {
|
|
16995
|
+
case "type_var":
|
|
16996
|
+
return true;
|
|
16997
|
+
case "array":
|
|
16998
|
+
return containsTypeVars(type.element);
|
|
16999
|
+
case "option":
|
|
17000
|
+
return containsTypeVars(type.inner);
|
|
17001
|
+
case "result":
|
|
17002
|
+
return containsTypeVars(type.ok) || containsTypeVars(type.err);
|
|
17003
|
+
case "fn_type":
|
|
17004
|
+
return type.params.some(containsTypeVars) || containsTypeVars(type.returnType);
|
|
17005
|
+
case "tuple":
|
|
17006
|
+
return type.elements.some(containsTypeVars);
|
|
17007
|
+
default:
|
|
17008
|
+
return false;
|
|
17009
|
+
}
|
|
17010
|
+
}
|
|
17011
|
+
|
|
16843
17012
|
// dist/checker/check.js
|
|
16844
17013
|
function typeCheck(module) {
|
|
16845
17014
|
const errors = [];
|
|
@@ -17161,13 +17330,28 @@ function inferCall(expr, env, errors, typeInfo) {
|
|
|
17161
17330
|
typeInfo.resolvedCallSiteEffects.set(expr.id, [...resolvedEffects]);
|
|
17162
17331
|
}
|
|
17163
17332
|
}
|
|
17333
|
+
const hasTypeVars = containsTypeVars(resolved.returnType) || resolved.params.some(containsTypeVars);
|
|
17334
|
+
const typeVarBindings = hasTypeVars ? unifyTypeVars(resolved.params, argTypes) : null;
|
|
17335
|
+
if (typeVarBindings && typeVarBindings.size > 0) {
|
|
17336
|
+
for (let i = 0; i < checkCount; i++) {
|
|
17337
|
+
const rawParam = resolved.params[i];
|
|
17338
|
+
if (!containsTypeVars(rawParam))
|
|
17339
|
+
continue;
|
|
17340
|
+
const concreteParam = substituteTypeVars(rawParam, typeVarBindings);
|
|
17341
|
+
const argType = argTypes[i];
|
|
17342
|
+
if (!isUnknown(argType)) {
|
|
17343
|
+
checkExpectedType(argType, concreteParam, expr.args[i].id, env, errors);
|
|
17344
|
+
}
|
|
17345
|
+
}
|
|
17346
|
+
}
|
|
17347
|
+
const concreteReturnType = typeVarBindings && typeVarBindings.size > 0 ? substituteTypeVars(resolved.returnType, typeVarBindings) : resolved.returnType;
|
|
17164
17348
|
if (expr.fn.kind === "ident") {
|
|
17165
17349
|
const builtin = BUILTIN_FUNCTIONS.get(expr.fn.name);
|
|
17166
17350
|
if (builtin?.provenance) {
|
|
17167
|
-
return { kind: "provenance", base:
|
|
17351
|
+
return { kind: "provenance", base: concreteReturnType, sources: [builtin.provenance] };
|
|
17168
17352
|
}
|
|
17169
17353
|
}
|
|
17170
|
-
return
|
|
17354
|
+
return concreteReturnType;
|
|
17171
17355
|
}
|
|
17172
17356
|
function inferIf(expr, env, errors, typeInfo) {
|
|
17173
17357
|
const condType = inferExpr(expr.condition, env, errors, typeInfo);
|
|
@@ -19258,6 +19442,22 @@ function getSupportedContainers() {
|
|
|
19258
19442
|
}
|
|
19259
19443
|
return cachedSupportedContainers;
|
|
19260
19444
|
}
|
|
19445
|
+
function containerMatchesSupported(concrete, supported) {
|
|
19446
|
+
if (supported.kind === "type_var")
|
|
19447
|
+
return true;
|
|
19448
|
+
if (concrete.kind !== supported.kind)
|
|
19449
|
+
return false;
|
|
19450
|
+
switch (concrete.kind) {
|
|
19451
|
+
case "array":
|
|
19452
|
+
return supported.kind === "array" && containerMatchesSupported(concrete.element, supported.element);
|
|
19453
|
+
case "option":
|
|
19454
|
+
return supported.kind === "option" && containerMatchesSupported(concrete.inner, supported.inner);
|
|
19455
|
+
case "result":
|
|
19456
|
+
return supported.kind === "result" && containerMatchesSupported(concrete.ok, supported.ok) && containerMatchesSupported(concrete.err, supported.err);
|
|
19457
|
+
default:
|
|
19458
|
+
return JSON.stringify(concrete) === JSON.stringify(supported);
|
|
19459
|
+
}
|
|
19460
|
+
}
|
|
19261
19461
|
function checkMonomorphicContainers(module, warnings) {
|
|
19262
19462
|
const supported = getSupportedContainers();
|
|
19263
19463
|
function checkType(type, nodeId, location) {
|
|
@@ -19265,8 +19465,7 @@ function checkMonomorphicContainers(module, warnings) {
|
|
|
19265
19465
|
return;
|
|
19266
19466
|
if (type.kind === "array" || type.kind === "option" || type.kind === "result") {
|
|
19267
19467
|
const supportedList = supported.get(type.kind) ?? [];
|
|
19268
|
-
|
|
19269
|
-
if (!supportedList.some((t) => JSON.stringify(t) === key)) {
|
|
19468
|
+
if (!supportedList.some((t) => containerMatchesSupported(type, t))) {
|
|
19270
19469
|
const suggestion = supportedList.length > 0 ? { nodeId, field: "type", value: supportedList[0] } : void 0;
|
|
19271
19470
|
warnings.push(unsupportedContainer(nodeId, location, type.kind, type, supportedList, suggestion));
|
|
19272
19471
|
}
|