hinmil 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +2306 -2
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +338 -0
- package/dist/cli.js.map +1 -0
- package/dist/commentParser.d.ts +384 -0
- package/dist/commentParser.d.ts.map +1 -0
- package/dist/commentParser.js +2487 -0
- package/dist/commentParser.js.map +1 -0
- package/dist/config.d.ts +203 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +375 -0
- package/dist/config.js.map +1 -0
- package/dist/debugLog.d.ts +13 -0
- package/dist/debugLog.d.ts.map +1 -0
- package/dist/debugLog.js +44 -0
- package/dist/debugLog.js.map +1 -0
- package/dist/estree.d.ts +100 -0
- package/dist/estree.d.ts.map +1 -0
- package/dist/estree.js +34 -0
- package/dist/estree.js.map +1 -0
- package/dist/hm/env.d.ts +134 -0
- package/dist/hm/env.d.ts.map +1 -0
- package/dist/hm/env.js +939 -0
- package/dist/hm/env.js.map +1 -0
- package/dist/hm/index.d.ts +7 -0
- package/dist/hm/index.d.ts.map +1 -0
- package/dist/hm/index.js +26 -0
- package/dist/hm/index.js.map +1 -0
- package/dist/hm/substitution.d.ts +57 -0
- package/dist/hm/substitution.d.ts.map +1 -0
- package/dist/hm/substitution.js +546 -0
- package/dist/hm/substitution.js.map +1 -0
- package/dist/hm/typeParser.d.ts +39 -0
- package/dist/hm/typeParser.d.ts.map +1 -0
- package/dist/hm/typeParser.js +1285 -0
- package/dist/hm/typeParser.js.map +1 -0
- package/dist/hm/typeUtils.d.ts +248 -0
- package/dist/hm/typeUtils.d.ts.map +1 -0
- package/dist/hm/typeUtils.js +905 -0
- package/dist/hm/typeUtils.js.map +1 -0
- package/dist/hm/types.d.ts +738 -0
- package/dist/hm/types.d.ts.map +1 -0
- package/dist/hm/types.js +1853 -0
- package/dist/hm/types.js.map +1 -0
- package/dist/hm/unify.d.ts +59 -0
- package/dist/hm/unify.d.ts.map +1 -0
- package/dist/hm/unify.js +1700 -0
- package/dist/hm/unify.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +196 -0
- package/dist/index.js.map +1 -0
- package/dist/infer/annotation-rigid.d.ts +76 -0
- package/dist/infer/annotation-rigid.d.ts.map +1 -0
- package/dist/infer/annotation-rigid.js +542 -0
- package/dist/infer/annotation-rigid.js.map +1 -0
- package/dist/infer/annotation-validation.d.ts +109 -0
- package/dist/infer/annotation-validation.d.ts.map +1 -0
- package/dist/infer/annotation-validation.js +1078 -0
- package/dist/infer/annotation-validation.js.map +1 -0
- package/dist/infer/annotations.d.ts +277 -0
- package/dist/infer/annotations.d.ts.map +1 -0
- package/dist/infer/annotations.js +1343 -0
- package/dist/infer/annotations.js.map +1 -0
- package/dist/infer/call-overloads.d.ts +24 -0
- package/dist/infer/call-overloads.d.ts.map +1 -0
- package/dist/infer/call-overloads.js +900 -0
- package/dist/infer/call-overloads.js.map +1 -0
- package/dist/infer/call-rows.d.ts +154 -0
- package/dist/infer/call-rows.d.ts.map +1 -0
- package/dist/infer/call-rows.js +2162 -0
- package/dist/infer/call-rows.js.map +1 -0
- package/dist/infer/calls.d.ts +20 -0
- package/dist/infer/calls.d.ts.map +1 -0
- package/dist/infer/calls.js +1468 -0
- package/dist/infer/calls.js.map +1 -0
- package/dist/infer/constraints.d.ts +99 -0
- package/dist/infer/constraints.d.ts.map +1 -0
- package/dist/infer/constraints.js +1208 -0
- package/dist/infer/constraints.js.map +1 -0
- package/dist/infer/expr-assignment.d.ts +20 -0
- package/dist/infer/expr-assignment.d.ts.map +1 -0
- package/dist/infer/expr-assignment.js +620 -0
- package/dist/infer/expr-assignment.js.map +1 -0
- package/dist/infer/expr-constraint-lookup.d.ts +44 -0
- package/dist/infer/expr-constraint-lookup.d.ts.map +1 -0
- package/dist/infer/expr-constraint-lookup.js +207 -0
- package/dist/infer/expr-constraint-lookup.js.map +1 -0
- package/dist/infer/expr-functions.d.ts +20 -0
- package/dist/infer/expr-functions.d.ts.map +1 -0
- package/dist/infer/expr-functions.js +1359 -0
- package/dist/infer/expr-functions.js.map +1 -0
- package/dist/infer/expr-jsx.d.ts +19 -0
- package/dist/infer/expr-jsx.d.ts.map +1 -0
- package/dist/infer/expr-jsx.js +310 -0
- package/dist/infer/expr-jsx.js.map +1 -0
- package/dist/infer/expr-member.d.ts +40 -0
- package/dist/infer/expr-member.d.ts.map +1 -0
- package/dist/infer/expr-member.js +1154 -0
- package/dist/infer/expr-member.js.map +1 -0
- package/dist/infer/expr-prototype.d.ts +11 -0
- package/dist/infer/expr-prototype.d.ts.map +1 -0
- package/dist/infer/expr-prototype.js +202 -0
- package/dist/infer/expr-prototype.js.map +1 -0
- package/dist/infer/expressions.d.ts +40 -0
- package/dist/infer/expressions.d.ts.map +1 -0
- package/dist/infer/expressions.js +1497 -0
- package/dist/infer/expressions.js.map +1 -0
- package/dist/infer/functionPatterns.d.ts +229 -0
- package/dist/infer/functionPatterns.d.ts.map +1 -0
- package/dist/infer/functionPatterns.js +1035 -0
- package/dist/infer/functionPatterns.js.map +1 -0
- package/dist/infer/helpers.d.ts +73 -0
- package/dist/infer/helpers.d.ts.map +1 -0
- package/dist/infer/helpers.js +187 -0
- package/dist/infer/helpers.js.map +1 -0
- package/dist/infer/index.d.ts +551 -0
- package/dist/infer/index.d.ts.map +1 -0
- package/dist/infer/index.js +1127 -0
- package/dist/infer/index.js.map +1 -0
- package/dist/infer/jsx-dom.d.ts +26 -0
- package/dist/infer/jsx-dom.d.ts.map +1 -0
- package/dist/infer/jsx-dom.js +303 -0
- package/dist/infer/jsx-dom.js.map +1 -0
- package/dist/infer/moduleReps.d.ts +7 -0
- package/dist/infer/moduleReps.d.ts.map +1 -0
- package/dist/infer/moduleReps.js +48 -0
- package/dist/infer/moduleReps.js.map +1 -0
- package/dist/infer/modules.d.ts +10 -0
- package/dist/infer/modules.d.ts.map +1 -0
- package/dist/infer/modules.js +775 -0
- package/dist/infer/modules.js.map +1 -0
- package/dist/infer/narrowing.d.ts +199 -0
- package/dist/infer/narrowing.d.ts.map +1 -0
- package/dist/infer/narrowing.js +1428 -0
- package/dist/infer/narrowing.js.map +1 -0
- package/dist/infer/results.d.ts +24 -0
- package/dist/infer/results.d.ts.map +1 -0
- package/dist/infer/results.js +611 -0
- package/dist/infer/results.js.map +1 -0
- package/dist/infer/setupPass.d.ts +11 -0
- package/dist/infer/setupPass.d.ts.map +1 -0
- package/dist/infer/setupPass.js +524 -0
- package/dist/infer/setupPass.js.map +1 -0
- package/dist/infer/statements.d.ts +26 -0
- package/dist/infer/statements.d.ts.map +1 -0
- package/dist/infer/statements.js +750 -0
- package/dist/infer/statements.js.map +1 -0
- package/dist/infer/stmt-bindings.d.ts +22 -0
- package/dist/infer/stmt-bindings.d.ts.map +1 -0
- package/dist/infer/stmt-bindings.js +1482 -0
- package/dist/infer/stmt-bindings.js.map +1 -0
- package/dist/infer/stmt-destructure.d.ts +29 -0
- package/dist/infer/stmt-destructure.d.ts.map +1 -0
- package/dist/infer/stmt-destructure.js +490 -0
- package/dist/infer/stmt-destructure.js.map +1 -0
- package/dist/infer/types.d.ts +220 -0
- package/dist/infer/types.d.ts.map +1 -0
- package/dist/infer/types.js +46 -0
- package/dist/infer/types.js.map +1 -0
- package/dist/infer/unifyDiag.d.ts +46 -0
- package/dist/infer/unifyDiag.d.ts.map +1 -0
- package/dist/infer/unifyDiag.js +642 -0
- package/dist/infer/unifyDiag.js.map +1 -0
- package/dist/parsing-babel.d.ts +3 -0
- package/dist/parsing-babel.d.ts.map +1 -0
- package/dist/parsing-babel.js +353 -0
- package/dist/parsing-babel.js.map +1 -0
- package/dist/parsing.d.ts +69 -0
- package/dist/parsing.d.ts.map +1 -0
- package/dist/parsing.js +288 -0
- package/dist/parsing.js.map +1 -0
- package/dist/registries/constraintRegistry.d.ts +233 -0
- package/dist/registries/constraintRegistry.d.ts.map +1 -0
- package/dist/registries/constraintRegistry.js +803 -0
- package/dist/registries/constraintRegistry.js.map +1 -0
- package/dist/registries/dataTypeRegistry.d.ts +63 -0
- package/dist/registries/dataTypeRegistry.d.ts.map +1 -0
- package/dist/registries/dataTypeRegistry.js +180 -0
- package/dist/registries/dataTypeRegistry.js.map +1 -0
- package/dist/registries/domGlobals.d.ts +33 -0
- package/dist/registries/domGlobals.d.ts.map +1 -0
- package/dist/registries/domGlobals.js +309 -0
- package/dist/registries/domGlobals.js.map +1 -0
- package/dist/registries/methodRegistry.d.ts +277 -0
- package/dist/registries/methodRegistry.d.ts.map +1 -0
- package/dist/registries/methodRegistry.js +2074 -0
- package/dist/registries/methodRegistry.js.map +1 -0
- package/dist/registries/session.d.ts +38 -0
- package/dist/registries/session.d.ts.map +1 -0
- package/dist/registries/session.js +75 -0
- package/dist/registries/session.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1896 -0
- package/dist/server.js.map +1 -0
- package/dist/services/codeActions.d.ts +22 -0
- package/dist/services/codeActions.d.ts.map +1 -0
- package/dist/services/codeActions.js +465 -0
- package/dist/services/codeActions.js.map +1 -0
- package/dist/services/completion.d.ts +259 -0
- package/dist/services/completion.d.ts.map +1 -0
- package/dist/services/completion.js +2794 -0
- package/dist/services/completion.js.map +1 -0
- package/dist/services/definitions.d.ts +37 -0
- package/dist/services/definitions.d.ts.map +1 -0
- package/dist/services/definitions.js +605 -0
- package/dist/services/definitions.js.map +1 -0
- package/dist/services/diagnosticCodes.d.ts +70 -0
- package/dist/services/diagnosticCodes.d.ts.map +1 -0
- package/dist/services/diagnosticCodes.js +239 -0
- package/dist/services/diagnosticCodes.js.map +1 -0
- package/dist/services/diagnostics.d.ts +86 -0
- package/dist/services/diagnostics.d.ts.map +1 -0
- package/dist/services/diagnostics.js +665 -0
- package/dist/services/diagnostics.js.map +1 -0
- package/dist/services/documentCache.d.ts +88 -0
- package/dist/services/documentCache.d.ts.map +1 -0
- package/dist/services/documentCache.js +108 -0
- package/dist/services/documentCache.js.map +1 -0
- package/dist/services/documentSymbols.d.ts +20 -0
- package/dist/services/documentSymbols.d.ts.map +1 -0
- package/dist/services/documentSymbols.js +381 -0
- package/dist/services/documentSymbols.js.map +1 -0
- package/dist/services/fileSelection.d.ts +24 -0
- package/dist/services/fileSelection.d.ts.map +1 -0
- package/dist/services/fileSelection.js +154 -0
- package/dist/services/fileSelection.js.map +1 -0
- package/dist/services/fileSelectionRefresh.d.ts +26 -0
- package/dist/services/fileSelectionRefresh.d.ts.map +1 -0
- package/dist/services/fileSelectionRefresh.js +77 -0
- package/dist/services/fileSelectionRefresh.js.map +1 -0
- package/dist/services/files.d.ts +342 -0
- package/dist/services/files.d.ts.map +1 -0
- package/dist/services/files.js +1712 -0
- package/dist/services/files.js.map +1 -0
- package/dist/services/fsProbe.d.ts +14 -0
- package/dist/services/fsProbe.d.ts.map +1 -0
- package/dist/services/fsProbe.js +112 -0
- package/dist/services/fsProbe.js.map +1 -0
- package/dist/services/globalsLoader.d.ts +20 -0
- package/dist/services/globalsLoader.d.ts.map +1 -0
- package/dist/services/globalsLoader.js +122 -0
- package/dist/services/globalsLoader.js.map +1 -0
- package/dist/services/hmFileServices.d.ts +113 -0
- package/dist/services/hmFileServices.d.ts.map +1 -0
- package/dist/services/hmFileServices.js +686 -0
- package/dist/services/hmFileServices.js.map +1 -0
- package/dist/services/hover.d.ts +280 -0
- package/dist/services/hover.d.ts.map +1 -0
- package/dist/services/hover.js +1687 -0
- package/dist/services/hover.js.map +1 -0
- package/dist/services/importContext.d.ts +396 -0
- package/dist/services/importContext.d.ts.map +1 -0
- package/dist/services/importContext.js +1999 -0
- package/dist/services/importContext.js.map +1 -0
- package/dist/services/projectChecker.d.ts +50 -0
- package/dist/services/projectChecker.d.ts.map +1 -0
- package/dist/services/projectChecker.js +228 -0
- package/dist/services/projectChecker.js.map +1 -0
- package/dist/services/references.d.ts +41 -0
- package/dist/services/references.d.ts.map +1 -0
- package/dist/services/references.js +757 -0
- package/dist/services/references.js.map +1 -0
- package/dist/services/rename.d.ts +22 -0
- package/dist/services/rename.d.ts.map +1 -0
- package/dist/services/rename.js +101 -0
- package/dist/services/rename.js.map +1 -0
- package/dist/services/shortCircuit.d.ts +27 -0
- package/dist/services/shortCircuit.d.ts.map +1 -0
- package/dist/services/shortCircuit.js +28 -0
- package/dist/services/shortCircuit.js.map +1 -0
- package/dist/services/sidecarPerf.d.ts +19 -0
- package/dist/services/sidecarPerf.d.ts.map +1 -0
- package/dist/services/sidecarPerf.js +59 -0
- package/dist/services/sidecarPerf.js.map +1 -0
- package/dist/services/signatureHelp.d.ts +27 -0
- package/dist/services/signatureHelp.d.ts.map +1 -0
- package/dist/services/signatureHelp.js +984 -0
- package/dist/services/signatureHelp.js.map +1 -0
- package/dist/walking.d.ts +25 -0
- package/dist/walking.d.ts.map +1 -0
- package/dist/walking.js +107 -0
- package/dist/walking.js.map +1 -0
- package/hm-types-builtin/assert.hm +20 -0
- package/hm-types-builtin/buffer.hm +8 -0
- package/hm-types-builtin/child_process.hm +16 -0
- package/hm-types-builtin/crypto.hm +17 -0
- package/hm-types-builtin/fs.hm +15 -0
- package/hm-types-builtin/http.hm +14 -0
- package/hm-types-builtin/os.hm +19 -0
- package/hm-types-builtin/path.hm +18 -0
- package/hm-types-builtin/react-dom.hm +27 -0
- package/hm-types-builtin/react.hm +113 -0
- package/hm-types-builtin/url.hm +7 -0
- package/hm-types-builtin/zlib.hm +12 -0
- package/package.json +53 -4
- package/schemas/hinmil.config.schema.json +261 -0
- package/schemas/package-hinmil.schema.json +59 -0
|
@@ -0,0 +1,1154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Member-expression inference: property access on unions, TypeReps, TCons,
|
|
4
|
+
// TVars, computed access, builtin constructors (extracted from expressions.ts)
|
|
5
|
+
//
|
|
6
|
+
// Plain language: this file answers "what is the type of `obj.something`?".
|
|
7
|
+
// That depends entirely on what `obj` is — a record with named fields, an
|
|
8
|
+
// array (with built-in methods like map), a class instance, a sum type
|
|
9
|
+
// variant, a union of several possibilities, … Each of those cases has its
|
|
10
|
+
// own lookup path here; if none of them knows the property, a diagnostic
|
|
11
|
+
// ("unknown property") is produced.
|
|
12
|
+
// ============================================================================
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.OBJECT_PROTOTYPE_METHOD_NAMES = void 0;
|
|
15
|
+
exports.inferMemberExpression = inferMemberExpression;
|
|
16
|
+
exports.objectPrototypeMethodType = objectPrototypeMethodType;
|
|
17
|
+
exports.builtinConstructorType = builtinConstructorType;
|
|
18
|
+
exports.flushDeferredMemberAccesses = flushDeferredMemberAccesses;
|
|
19
|
+
const types_1 = require("../hm/types");
|
|
20
|
+
const types_2 = require("../hm/types");
|
|
21
|
+
const env_1 = require("../hm/env");
|
|
22
|
+
const unify_1 = require("../hm/unify");
|
|
23
|
+
const methodRegistry_1 = require("../registries/methodRegistry");
|
|
24
|
+
const constraintRegistry_1 = require("../registries/constraintRegistry");
|
|
25
|
+
const dataTypeRegistry_1 = require("../registries/dataTypeRegistry");
|
|
26
|
+
const typeUtils_1 = require("../hm/typeUtils");
|
|
27
|
+
const narrowing_1 = require("./narrowing");
|
|
28
|
+
const helpers_1 = require("./helpers");
|
|
29
|
+
const expr_constraint_lookup_1 = require("./expr-constraint-lookup");
|
|
30
|
+
const expressions_1 = require("./expressions");
|
|
31
|
+
function inferMemberExpression(engine, node, env) {
|
|
32
|
+
const type = inferMemberExpressionRaw(engine, node, env);
|
|
33
|
+
// A branch narrowed by `obj.prop == null` on a non-record object marks the
|
|
34
|
+
// path as non-null (see `narrowing.ts`, member null check).
|
|
35
|
+
if (!node.computed && node.object?.type === 'Identifier' && node.property?.type === 'Identifier'
|
|
36
|
+
&& env.lookup((0, narrowing_1.nonNullMemberKey)(node.object.name, node.property.name))) {
|
|
37
|
+
return (0, narrowing_1.removeNullUndefined)(engine.subst.apply(type));
|
|
38
|
+
}
|
|
39
|
+
return type;
|
|
40
|
+
}
|
|
41
|
+
function inferMemberExpressionRaw(engine, node, env) {
|
|
42
|
+
const objectType = (0, expressions_1.inferExpression)(engine, node.object, env);
|
|
43
|
+
let resolved = engine.subst.apply(objectType);
|
|
44
|
+
// Expand type aliases (e.g., TCon('Person') from recursive type references)
|
|
45
|
+
// so that record field access and method lookup work on the expanded type.
|
|
46
|
+
resolved = engine.maybeExpandAlias(resolved);
|
|
47
|
+
// --- A member of `Any` is `Any` (`json.data` after `JSON.parse` typed as
|
|
48
|
+
// `Any`): a fresh variable would pin on first use and leave a later
|
|
49
|
+
// `Object.assign ({}, json.data, x)` with an unresolvable operand.
|
|
50
|
+
if ((0, types_2.isAnyType)(resolved)) {
|
|
51
|
+
engine.recordNodeType(node.property, types_2.tAnyType);
|
|
52
|
+
return types_2.tAnyType;
|
|
53
|
+
}
|
|
54
|
+
// --- Computed access: arr[i] => element type ---
|
|
55
|
+
if (node.computed) {
|
|
56
|
+
return inferComputedAccess(engine, node, env, objectType, resolved);
|
|
57
|
+
}
|
|
58
|
+
// --- Property access: obj.prop or obj.#privateField ---
|
|
59
|
+
// PrivateIdentifier nodes also expose `.name` (without the leading '#').
|
|
60
|
+
const propIsPrivate = node.property?.type === 'PrivateIdentifier';
|
|
61
|
+
const propName = node.property.name;
|
|
62
|
+
if (!propName)
|
|
63
|
+
return (0, types_2.tVar)();
|
|
64
|
+
// Private fields/methods (`obj.#x`, `this.#m()`) are class-scoped and not
|
|
65
|
+
// tracked in the public method/property registries. If we know the
|
|
66
|
+
// receiver's class and have stashed the private member's type during
|
|
67
|
+
// class inference (via a `Class##name :: T` annotation or initialiser),
|
|
68
|
+
// return that type so hover / completion work inside the class body.
|
|
69
|
+
// Otherwise return a fresh TVar to suppress "property does not exist".
|
|
70
|
+
if (propIsPrivate) {
|
|
71
|
+
let privType = (0, types_2.tVar)();
|
|
72
|
+
if (resolved.tag === 'TCon') {
|
|
73
|
+
const stored = engine.privateClassMembers.get(`${resolved.name}##${propName}`);
|
|
74
|
+
if (stored)
|
|
75
|
+
privType = (0, env_1.instantiate)((0, env_1.generalize)(env, stored));
|
|
76
|
+
}
|
|
77
|
+
engine.recordNodeType(node.property, privType);
|
|
78
|
+
return privType;
|
|
79
|
+
}
|
|
80
|
+
// Record field access (structural)
|
|
81
|
+
if (resolved.tag === 'TRecord' && Object.prototype.hasOwnProperty.call(resolved.fields, propName)) {
|
|
82
|
+
// If this field carries a stored Scheme (recorded at annotated
|
|
83
|
+
// member-assignment time), re-instantiate it freshly per use site.
|
|
84
|
+
// This makes call-site argument unification AND constraint validation
|
|
85
|
+
// happen at THIS access, instead of reusing the assignment-site
|
|
86
|
+
// instantiation. Works for any access path — direct (`Param.Query`),
|
|
87
|
+
// aliased (`const A = Param; A.Query`), or via a returned record —
|
|
88
|
+
// because the metadata travels with the record value itself.
|
|
89
|
+
if (resolved.fieldSchemes && Object.prototype.hasOwnProperty.call(resolved.fieldSchemes, propName)) {
|
|
90
|
+
const fresh = engine.instantiateWithConstraints(resolved.fieldSchemes[propName], node, undefined);
|
|
91
|
+
engine.recordNodeType(node.property, fresh);
|
|
92
|
+
return fresh;
|
|
93
|
+
}
|
|
94
|
+
// Fallback: dotted-name annotation lookup (covers cases where the
|
|
95
|
+
// record's `fieldSchemes` map wasn't populated — e.g. when the
|
|
96
|
+
// assignment didn't go through the annotated branch but the
|
|
97
|
+
// annotation still exists on the dotted name).
|
|
98
|
+
if (node.object.type === 'Identifier') {
|
|
99
|
+
const dottedName = `${node.object.name}.${propName}`;
|
|
100
|
+
const ann = engine.annotationMap.get(dottedName);
|
|
101
|
+
if (ann?.scheme) {
|
|
102
|
+
const fresh = engine.instantiateWithConstraints(ann.scheme, node, ann);
|
|
103
|
+
engine.recordNodeType(node.property, fresh);
|
|
104
|
+
return fresh;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const fieldType = resolved.fields[propName];
|
|
108
|
+
engine.recordNodeType(node.property, fieldType);
|
|
109
|
+
return fieldType;
|
|
110
|
+
}
|
|
111
|
+
// Record type but field doesn't exist → fall back to Object.prototype
|
|
112
|
+
// built-ins (`toString`, `valueOf`, …) before reporting a missing field.
|
|
113
|
+
if (resolved.tag === 'TRecord') {
|
|
114
|
+
const builtin = objectPrototypeMethodType(propName);
|
|
115
|
+
if (builtin) {
|
|
116
|
+
engine.recordNodeType(node.property, builtin);
|
|
117
|
+
return builtin;
|
|
118
|
+
}
|
|
119
|
+
// User-defined `Object#method` (e.g. `Object#concat`) resolves on *any*
|
|
120
|
+
// record form (`{}`, `{a}`, `{...a}`, `{[i]::a}`, `{x::T}`). The receiver
|
|
121
|
+
// row stored on the method entry is unified with the actual record so its
|
|
122
|
+
// fields bind; the label↔row bridge (unify.ts) reconciles the differing
|
|
123
|
+
// record spellings.
|
|
124
|
+
const objEntry = (0, methodRegistry_1.lookupMethod)('Object', propName);
|
|
125
|
+
if (objEntry && !objEntry.isStatic) {
|
|
126
|
+
if (objEntry.recordReceiver && objEntry.recordMethodType && objEntry.recordScheme) {
|
|
127
|
+
const synthAnn = {
|
|
128
|
+
receiver: objEntry.recordReceiver,
|
|
129
|
+
methodType: objEntry.recordMethodType,
|
|
130
|
+
scheme: objEntry.recordScheme,
|
|
131
|
+
};
|
|
132
|
+
const { thisType, expectedType } = engine.coordinateInstantiate(synthAnn);
|
|
133
|
+
engine.unifyWithDiagnostic(thisType, resolved, node.object);
|
|
134
|
+
const methodType = engine.resolve(expectedType);
|
|
135
|
+
engine.recordNodeType(node.property, methodType);
|
|
136
|
+
engine.methodSignatures.set(node.property.start, `Object#${propName} :: ${(0, types_2.prettyTypeToString)(methodType)}`);
|
|
137
|
+
return methodType;
|
|
138
|
+
}
|
|
139
|
+
// Shorthand property/method annotation: `Object#prop :: T`.
|
|
140
|
+
const methodType = objEntry.factory([]);
|
|
141
|
+
engine.recordNodeType(node.property, methodType);
|
|
142
|
+
engine.methodSignatures.set(node.property.start, `Object#${propName} :: ${(0, types_2.prettyTypeToString)(methodType)}`);
|
|
143
|
+
return methodType;
|
|
144
|
+
}
|
|
145
|
+
// An open record whose row is still a free variable gains the field:
|
|
146
|
+
// `{ paid :: Boolean, ...r }` (a library signature such as
|
|
147
|
+
// `prop :: k -> { [k] :: a, ...r } -> a`, applied before the data is
|
|
148
|
+
// known) read as `o.total` becomes `{ paid :: Boolean, total :: t, ...r' }`.
|
|
149
|
+
// The row of a parameter checked against its own annotation is that
|
|
150
|
+
// annotation's promise: a field outside it stays an error.
|
|
151
|
+
if (resolved.rest && (resolved.rest.tag === 'TVar' || resolved.rest.tag === 'TRow')
|
|
152
|
+
&& !(0, types_2.isSkolem)(resolved.rest) && !engine.rigidRowIds.has(resolved.rest.id)) {
|
|
153
|
+
const fieldType = (0, types_2.tVar)();
|
|
154
|
+
try {
|
|
155
|
+
const extension = (0, types_1.tOpenRecord)({ [propName]: fieldType }, (0, types_1.tRow)(resolved.rest.tag === 'TRow' ? resolved.rest.name : undefined));
|
|
156
|
+
engine.subst = engine.subst.compose((0, unify_1.unify)(engine.subst.apply(resolved.rest), extension));
|
|
157
|
+
const applied = engine.subst.apply(fieldType);
|
|
158
|
+
engine.recordNodeType(node.property, applied);
|
|
159
|
+
return applied;
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
if (!(e instanceof unify_1.UnificationError))
|
|
163
|
+
throw e;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
engine.addDiag(`Property '${propName}' does not exist on type '${(0, types_2.typeToString)(resolved)}'`, node.property);
|
|
167
|
+
const errType = (0, types_2.tVar)();
|
|
168
|
+
engine.recordNodeType(node.property, errType);
|
|
169
|
+
return errType;
|
|
170
|
+
}
|
|
171
|
+
// Union type: check each member for the property.
|
|
172
|
+
if ((0, types_2.isUnion)(resolved) && resolved.args.length > 0) {
|
|
173
|
+
return inferUnionPropertyAccess(engine, node, resolved, propName);
|
|
174
|
+
}
|
|
175
|
+
// Check registry for container/type methods (instance methods on TCon values)
|
|
176
|
+
if (resolved.tag === 'TCon') {
|
|
177
|
+
// Open index-signature object `Object k a` (≅ `{ [k] :: a }`): every key
|
|
178
|
+
// resolves to the homogeneous value type `a`. Used by e.g. `process.env`
|
|
179
|
+
// (`process.env.NODE_ENV :: String`). Prototype methods (`toString`,
|
|
180
|
+
// `valueOf`, …) and `.constructor` still resolve normally.
|
|
181
|
+
if (resolved.name === 'Object' && resolved.args.length === 2 && propName !== 'constructor') {
|
|
182
|
+
const builtin = objectPrototypeMethodType(propName);
|
|
183
|
+
if (builtin) {
|
|
184
|
+
engine.recordNodeType(node.property, builtin);
|
|
185
|
+
return builtin;
|
|
186
|
+
}
|
|
187
|
+
const valueType = engine.subst.apply(resolved.args[1]);
|
|
188
|
+
engine.recordNodeType(node.property, valueType);
|
|
189
|
+
return valueType;
|
|
190
|
+
}
|
|
191
|
+
// Check for kind-variable constraint methods first
|
|
192
|
+
const kv = (0, types_2.parseKvName)(resolved.name);
|
|
193
|
+
if (kv) {
|
|
194
|
+
// .constructor on a kv-constrained type: return TypeRep wrapping
|
|
195
|
+
// the full applied type (e.g. TypeRep (f a)). Constraints are
|
|
196
|
+
// looked up from the inner type's kv var during method access.
|
|
197
|
+
if (propName === 'constructor') {
|
|
198
|
+
const typeRepType = (0, types_2.tCon)(types_2.T_TYPEREP, [resolved]);
|
|
199
|
+
engine.recordNodeType(node.property, typeRepType);
|
|
200
|
+
return typeRepType;
|
|
201
|
+
}
|
|
202
|
+
const constraintMethod = (0, expr_constraint_lookup_1.lookupConstraintMethod)(engine, kv.varId, propName, resolved, node);
|
|
203
|
+
if (constraintMethod)
|
|
204
|
+
return constraintMethod;
|
|
205
|
+
// Kind variable with no matching constraint method — emit a diagnostic
|
|
206
|
+
// if there's a constraint for this kv.
|
|
207
|
+
const cNames = (0, expr_constraint_lookup_1.resolveKvConstraintNames)(engine.kvConstraints, engine.subst, kv.varId, resolved.name);
|
|
208
|
+
// Also check applied kind * constraints (e.g. Semigroup (s a))
|
|
209
|
+
const ctorCNames = (0, expr_constraint_lookup_1.resolveKvConstraintNames)(engine.kvConstructorConstraints, engine.subst, kv.varId, resolved.name);
|
|
210
|
+
const kindStarCtorNames = (ctorCNames ?? []).filter(cn => {
|
|
211
|
+
const baseName = (0, types_2.constraintBaseName)(cn);
|
|
212
|
+
const def = (0, constraintRegistry_1.lookupConstraint)(baseName);
|
|
213
|
+
return def?.expectedKind === '*';
|
|
214
|
+
});
|
|
215
|
+
const allConstraintNames = [...(cNames ?? []), ...kindStarCtorNames];
|
|
216
|
+
if (allConstraintNames.length > 0 && !isBuiltInJsProperty(propName)) {
|
|
217
|
+
return recordPropertyError(engine, node.property, `Property '${propName}' does not exist on constraint '${allConstraintNames.join(', ')}'`);
|
|
218
|
+
}
|
|
219
|
+
const kvErr = (0, types_2.tVar)();
|
|
220
|
+
engine.recordNodeType(node.property, kvErr);
|
|
221
|
+
return kvErr;
|
|
222
|
+
}
|
|
223
|
+
// TypeRep member access: static constraint methods on the type-rep.
|
|
224
|
+
if (resolved.name === types_2.T_TYPEREP && resolved.args.length === 1) {
|
|
225
|
+
return inferTypeRepPropertyAccess(engine, node, resolved, propName, env);
|
|
226
|
+
}
|
|
227
|
+
// .constructor on a concrete TCon
|
|
228
|
+
if (propName === 'constructor') {
|
|
229
|
+
const ctorResult = inferTConConstructorAccess(engine, node, resolved, env);
|
|
230
|
+
if (ctorResult)
|
|
231
|
+
return ctorResult;
|
|
232
|
+
}
|
|
233
|
+
// Private member access check: `obj.priv` from outside the class /
|
|
234
|
+
// prototype is an error. `this.priv` from inside (where `this` is
|
|
235
|
+
// bound to the same TCon) is allowed. Method/field still resolves
|
|
236
|
+
// normally so hover and signature help work.
|
|
237
|
+
if ((0, methodRegistry_1.isMethodPrivate)(resolved.name, propName) && node.object.type !== 'ThisExpression') {
|
|
238
|
+
engine.addDiag(`Property '${propName}' is private to type '${resolved.name}'`, node.property);
|
|
239
|
+
}
|
|
240
|
+
const entry = (0, methodRegistry_1.lookupMethod)(resolved.name, propName);
|
|
241
|
+
if (entry && !entry.isStatic) {
|
|
242
|
+
return inferTConInstanceMethod(engine, node, resolved, propName, entry, env);
|
|
243
|
+
}
|
|
244
|
+
// Static method on the TCon value (e.g. `this.constructor.of(x)` after
|
|
245
|
+
// `.constructor` was typed as the sumtype value). When the receiver is
|
|
246
|
+
// a value typed as `Either e a`, lookups like `.of` should still find
|
|
247
|
+
// `Either.of`. This mirrors the identifier-based path in
|
|
248
|
+
// `inferStaticMethodAccess`.
|
|
249
|
+
if (entry && entry.isStatic) {
|
|
250
|
+
const methodType = entry.scheme?.constraints?.length
|
|
251
|
+
? engine.instantiateWithConstraints(entry.scheme, node)
|
|
252
|
+
: entry.factory([]);
|
|
253
|
+
engine.recordNodeType(node.property, methodType);
|
|
254
|
+
engine.methodSignatures.set(node.property.start, `${resolved.name}.${propName} :: ${(0, types_2.prettyTypeToString)(methodType)}`);
|
|
255
|
+
return methodType;
|
|
256
|
+
}
|
|
257
|
+
// No matching instance method found on this TCon type.
|
|
258
|
+
// If the type has any registered methods at all, the property is likely
|
|
259
|
+
// a mistake — emit a diagnostic. Skip properties that were assigned
|
|
260
|
+
// via `this.prop = ...` in the constructor (unannotated but valid).
|
|
261
|
+
if (!entry) {
|
|
262
|
+
// DOM/Fetch nominal types (Document, Element, Response, …) carry a
|
|
263
|
+
// deliberately COMPACT method catalogue — anything not listed silently
|
|
264
|
+
// resolves to `Any` instead of erroring, mirroring the open-world
|
|
265
|
+
// philosophy for the huge browser API surface (see domGlobals.ts).
|
|
266
|
+
if ((0, methodRegistry_1.hasAnyFallbackMethods)(resolved.name) && !isBuiltInJsProperty(propName)) {
|
|
267
|
+
engine.recordNodeType(node.property, types_2.tAnyType);
|
|
268
|
+
return types_2.tAnyType;
|
|
269
|
+
}
|
|
270
|
+
const knownNames = (0, methodRegistry_1.getMethodNames)(resolved.name);
|
|
271
|
+
if (knownNames.length > 0
|
|
272
|
+
&& !isBuiltInJsProperty(propName)
|
|
273
|
+
&& !engine.constructorProperties.has(`${resolved.name}#${propName}`)) {
|
|
274
|
+
// Record-style sumtype variants name their carried fields, e.g.
|
|
275
|
+
// `Component :: | Engine { ext :: String, handler :: EngineFn } | ...`
|
|
276
|
+
// A `Component ~>` method (typically `matchWith`) may read those
|
|
277
|
+
// fields off `this` even though no constructor assigns them and no
|
|
278
|
+
// `Component#ext` annotation was written. Accept such a field access
|
|
279
|
+
// automatically from the declaration and surface the declared field
|
|
280
|
+
// type on hover.
|
|
281
|
+
const recordFieldType = (0, dataTypeRegistry_1.getVariantRecordFields)(resolved.name).get(propName);
|
|
282
|
+
if (recordFieldType !== undefined) {
|
|
283
|
+
engine.methodSignatures.set(node.property.start, `${resolved.name}#${propName} :: ${recordFieldType}`);
|
|
284
|
+
return recordSuppressedProperty(engine, node.property);
|
|
285
|
+
}
|
|
286
|
+
return recordPropertyError(engine, node.property, `Property '${propName}' does not exist on type ${(0, types_2.prettyTypeToString)(resolved)}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// Check registry for static methods using the identifier name (e.g. Box.fromPair)
|
|
291
|
+
if (node.object.type === 'Identifier') {
|
|
292
|
+
const staticResult = inferStaticMethodAccess(engine, node, propName);
|
|
293
|
+
if (staticResult)
|
|
294
|
+
return staticResult;
|
|
295
|
+
}
|
|
296
|
+
// If it's a type var, first check for constraint-based method lookup.
|
|
297
|
+
// When the TVar has a constraint (e.g. Monad m), static method access on
|
|
298
|
+
// the bare type variable is blocked — use TypeRep m instead.
|
|
299
|
+
// However, for kind * constraints (e.g. Semigroup s), instance methods
|
|
300
|
+
// should be accessible directly since s is a concrete value, not a constructor.
|
|
301
|
+
if (resolved.tag === 'TVar') {
|
|
302
|
+
const tvarResult = inferTVarPropertyAccess(engine, node, resolved, propName, objectType);
|
|
303
|
+
if (tvarResult)
|
|
304
|
+
return tvarResult;
|
|
305
|
+
}
|
|
306
|
+
// Property access on a function type (TFun): look up static methods by
|
|
307
|
+
// the function's return type (e.g. building.constructor.create).
|
|
308
|
+
if (resolved.tag === 'TFun') {
|
|
309
|
+
const funBuiltin = inferTFunBuiltinMethod(engine, node, resolved, propName);
|
|
310
|
+
if (funBuiltin)
|
|
311
|
+
return funBuiltin;
|
|
312
|
+
const funStaticResult = inferFunStaticMethodAccess(engine, node, resolved, propName);
|
|
313
|
+
if (funStaticResult)
|
|
314
|
+
return funStaticResult;
|
|
315
|
+
}
|
|
316
|
+
// Wildcard type (e.g. *:a from an unconstrained annotation parameter) —
|
|
317
|
+
// the type is explicitly generic, so property access cannot be resolved.
|
|
318
|
+
// Mark for hover suppression but do not emit a diagnostic — the user may
|
|
319
|
+
// intentionally use a generic parameter without constraints.
|
|
320
|
+
// A rigid skolem (the parameter of a body checked against its annotation)
|
|
321
|
+
// is the same generic parameter, so it is treated alike.
|
|
322
|
+
if ((0, types_2.isWildcard)(resolved) || (0, types_2.isSkolem)(resolved)) {
|
|
323
|
+
return recordSuppressedProperty(engine, node.property);
|
|
324
|
+
}
|
|
325
|
+
// Property access on an unconstrained type variable — we don't know if
|
|
326
|
+
// this property exists. Record a dummy type so the property node wins
|
|
327
|
+
// as most-specific hover match, then mark for suppression. Also park the
|
|
328
|
+
// access for late re-resolution: a later unification may pin the receiver
|
|
329
|
+
// (e.g. `myMap(s => s.length)(["aa"])` — the data argument arrives after
|
|
330
|
+
// the callback), at which point the member lookup is retried and the
|
|
331
|
+
// dummy var is unified with the real member type.
|
|
332
|
+
if (resolved.tag === 'TVar') {
|
|
333
|
+
const suppressed = recordSuppressedProperty(engine, node.property);
|
|
334
|
+
engine.deferredMemberAccesses.push({
|
|
335
|
+
objType: resolved,
|
|
336
|
+
propName,
|
|
337
|
+
resultType: suppressed,
|
|
338
|
+
propStart: node.property.start,
|
|
339
|
+
});
|
|
340
|
+
return suppressed;
|
|
341
|
+
}
|
|
342
|
+
const fallback = (0, types_2.tVar)();
|
|
343
|
+
engine.recordNodeType(node.property, fallback);
|
|
344
|
+
return fallback;
|
|
345
|
+
}
|
|
346
|
+
// -----------------------------------------------------------------------
|
|
347
|
+
// inferMemberExpression helpers
|
|
348
|
+
// -----------------------------------------------------------------------
|
|
349
|
+
/** Handle property access on a union type: check each member and collect results. */
|
|
350
|
+
function inferUnionPropertyAccess(engine, node, resolved, propName) {
|
|
351
|
+
// Variant-union shortcut (e.g. `Just a | Nothing`): when every member is
|
|
352
|
+
// a variant of the same parent sumtype and the parent has `propName`
|
|
353
|
+
// (typically `.of` or another inherited static), resolve through the
|
|
354
|
+
// parent ONCE so we get a single sharp signature instead of a union of
|
|
355
|
+
// freshly-instantiated factories.
|
|
356
|
+
{
|
|
357
|
+
const variantMembers = resolved.args.filter((m) => m.tag === 'TCon' && m.name !== types_2.T_UNION);
|
|
358
|
+
if (variantMembers.length === resolved.args.length && variantMembers.length > 0) {
|
|
359
|
+
const parentNames = variantMembers.map(m => (0, dataTypeRegistry_1.getParentTypeName)(m.name));
|
|
360
|
+
const parent = parentNames[0];
|
|
361
|
+
if (parent && parentNames.every(n => n === parent)) {
|
|
362
|
+
const entry = (0, methodRegistry_1.lookupMethod)(parent, propName);
|
|
363
|
+
if (entry) {
|
|
364
|
+
const parentArity = (0, methodRegistry_1.getTypeArity)(parent);
|
|
365
|
+
const parentArgs = Array.from({ length: parentArity }, () => (0, types_2.tVar)());
|
|
366
|
+
const methodType = entry.factory(parentArgs);
|
|
367
|
+
engine.recordNodeType(node.property, methodType);
|
|
368
|
+
return methodType;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const memberResults = [];
|
|
374
|
+
const badMembers = [];
|
|
375
|
+
// Track whether we silently skipped any TFun branches. Function values
|
|
376
|
+
// in an overload union (from repeated `Name :: ...` declarations) have
|
|
377
|
+
// no fields, so accessing a property on the union is interpreted as
|
|
378
|
+
// accessing it on the non-callable side; we don't want to flag the
|
|
379
|
+
// function branches as "missing property".
|
|
380
|
+
let skippedFunBranch = false;
|
|
381
|
+
// Track unresolved (type-variable) members. A member that is still an
|
|
382
|
+
// unconstrained variable — e.g. the default export of a module that could
|
|
383
|
+
// not be inferred — says nothing about the property either way. Property
|
|
384
|
+
// access on a single TVar is permissive, so stay consistent for unions
|
|
385
|
+
// instead of flagging every unresolved member as "missing property".
|
|
386
|
+
let skippedUnresolvedBranch = false;
|
|
387
|
+
// A union with an `Any` member is `Any` for property access: the unknown
|
|
388
|
+
// member may have the property (TypeScript's `__importDefault` helper
|
|
389
|
+
// returns `{ default :: a } | a` with `a := Any` for `require (…)`).
|
|
390
|
+
if (resolved.args.some(m => (0, types_2.isAnyType)(engine.maybeExpandAlias(m)))) {
|
|
391
|
+
engine.recordNodeType(node.property, types_2.tAnyType);
|
|
392
|
+
return types_2.tAnyType;
|
|
393
|
+
}
|
|
394
|
+
for (const member of resolved.args) {
|
|
395
|
+
const expanded = engine.maybeExpandAlias(member);
|
|
396
|
+
if (expanded.tag === 'TRecord' && propName in expanded.fields) {
|
|
397
|
+
memberResults.push(expanded.fields[propName]);
|
|
398
|
+
}
|
|
399
|
+
else if (expanded.tag === 'TCon' && expanded.name !== types_2.T_UNION) {
|
|
400
|
+
let entry = (0, methodRegistry_1.lookupMethod)(expanded.name, propName);
|
|
401
|
+
let lookupArgs = expanded.args;
|
|
402
|
+
// Variant member of a sumtype: try the parent sumtype for inherited
|
|
403
|
+
// methods (e.g. `Maybe.of` on a `Just a | Nothing` union).
|
|
404
|
+
if (!entry) {
|
|
405
|
+
const parentName = (0, dataTypeRegistry_1.getParentTypeName)(expanded.name);
|
|
406
|
+
if (parentName) {
|
|
407
|
+
entry = (0, methodRegistry_1.lookupMethod)(parentName, propName);
|
|
408
|
+
if (entry) {
|
|
409
|
+
// Use parent's type-arg arity rather than the variant's so the
|
|
410
|
+
// factory receives the right number of args.
|
|
411
|
+
const parentArity = (0, methodRegistry_1.getTypeArity)(parentName);
|
|
412
|
+
lookupArgs = Array.from({ length: parentArity }, (_, i) => expanded.args[i] ?? (0, types_2.tVar)());
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (entry) {
|
|
417
|
+
const methodType = entry.factory(lookupArgs);
|
|
418
|
+
// Identity-on-receiver methods (e.g. `Table p ~> [a] -> Table p`)
|
|
419
|
+
// declare that calling the method preserves the receiver shape.
|
|
420
|
+
// When the receiver is part of an overloaded-constructor union
|
|
421
|
+
// (skippedFunBranch === true), preserving only the matched
|
|
422
|
+
// member discards the other overloads; rewrite the method's
|
|
423
|
+
// return type to the WHOLE union so downstream call sites
|
|
424
|
+
// still see all overloads (e.g. selector overloads).
|
|
425
|
+
if (methodType.tag === 'TFun'
|
|
426
|
+
&& (0, typeUtils_1.structuralEquals)(methodType.result, expanded)) {
|
|
427
|
+
memberResults.push({ ...methodType, result: resolved });
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
memberResults.push(methodType);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
badMembers.push((0, types_2.prettyTypeToString)(member));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else if (expanded.tag === 'TFun') {
|
|
438
|
+
skippedFunBranch = true;
|
|
439
|
+
}
|
|
440
|
+
else if (expanded.tag === 'TVar' || expanded.tag === 'TRow') {
|
|
441
|
+
skippedUnresolvedBranch = true;
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
badMembers.push((0, types_2.prettyTypeToString)(member));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (badMembers.length > 0) {
|
|
448
|
+
// Overloaded-constructor unions mix value-shapes with at least one
|
|
449
|
+
// callable (TFun) overload — e.g. query-builder's
|
|
450
|
+
// `Caregiver :: ({ props :: … } | Table CaregiverRow | ([CaregiverSelector] -> QueryTag p (Picked …)))`.
|
|
451
|
+
// A method like `Table#addProps` is defined for the `Table` view only;
|
|
452
|
+
// the `{props}` view is metadata and the call-overload is irrelevant
|
|
453
|
+
// for property access. When at least one branch DID resolve the
|
|
454
|
+
// property AND the union carries a TFun overload, treat that as a
|
|
455
|
+
// narrowed access (pick the resolving member) rather than flagging
|
|
456
|
+
// the metadata branches as "missing". Without this, the failing
|
|
457
|
+
// diagnostic causes the host binding (`const U = X.addProps([...])`)
|
|
458
|
+
// to fall back to a bare TVar, which then silently swallows further
|
|
459
|
+
// type errors at every later use site.
|
|
460
|
+
if (memberResults.length > 0 && skippedFunBranch) {
|
|
461
|
+
const resultType = memberResults.length === 1 ? memberResults[0] : (0, types_2.tUnion)(memberResults);
|
|
462
|
+
engine.recordNodeType(node.property, resultType);
|
|
463
|
+
return resultType;
|
|
464
|
+
}
|
|
465
|
+
engine.addDiag(`Property '${propName}' does not exist on type${badMembers.length > 1 ? 's' : ''} ${badMembers.map(m => `'${m}'`).join(', ')} in union '${(0, types_2.prettyTypeToString)(resolved)}'`, node.property);
|
|
466
|
+
const suppressedType = memberResults.length > 0
|
|
467
|
+
? (memberResults.length === 1 ? memberResults[0] : (0, types_2.tUnion)(memberResults))
|
|
468
|
+
: (0, types_2.tVar)();
|
|
469
|
+
engine.recordNodeType(node.property, suppressedType);
|
|
470
|
+
engine.unconstrainedPropAccesses.add(node.property.start);
|
|
471
|
+
return suppressedType;
|
|
472
|
+
}
|
|
473
|
+
if (memberResults.length > 0) {
|
|
474
|
+
const resultType = memberResults.length === 1 ? memberResults[0] : (0, types_2.tUnion)(memberResults);
|
|
475
|
+
engine.recordNodeType(node.property, resultType);
|
|
476
|
+
return resultType;
|
|
477
|
+
}
|
|
478
|
+
const errType = (0, types_2.tVar)();
|
|
479
|
+
engine.recordNodeType(node.property, errType);
|
|
480
|
+
// Suppress unconstrainedPropAccess marker only when we silently skipped
|
|
481
|
+
// a TFun branch — that means the overload union was intentionally used
|
|
482
|
+
// for callability, and the access is valid at runtime even if no
|
|
483
|
+
// non-function branch resolved the prop. Unresolved (TVar) branches are
|
|
484
|
+
// equally inconclusive, so they suppress the marker too. Otherwise mark
|
|
485
|
+
// as unresolved.
|
|
486
|
+
if (!skippedFunBranch && !skippedUnresolvedBranch) {
|
|
487
|
+
engine.unconstrainedPropAccesses.add(node.property.start);
|
|
488
|
+
}
|
|
489
|
+
return errType;
|
|
490
|
+
}
|
|
491
|
+
/** Handle TypeRep member access: static constraint methods on TypeRep (f a). */
|
|
492
|
+
/**
|
|
493
|
+
* A static reached through a type representative produces values of THAT
|
|
494
|
+
* representative's type: `IdMaybe.of :: a -> IdT m a` through
|
|
495
|
+
* `IdMaybe :: TypeRep (IdT Maybe)` is `a -> IdT Maybe a`. Unify the leading
|
|
496
|
+
* arguments of the static's result `T …` with the witness `T x1 … xk`
|
|
497
|
+
* (best-effort: a static that returns something else is left alone).
|
|
498
|
+
* Without this the monad of a transformer instance (`StateT (Either)`,
|
|
499
|
+
* `IdT (Maybe)`) was forgotten by every static (`of`, `lift`, `ask`, …).
|
|
500
|
+
*/
|
|
501
|
+
function bindStaticToWitness(engine, staticType, witness) {
|
|
502
|
+
if (witness.args.length === 0)
|
|
503
|
+
return;
|
|
504
|
+
const ret = engine.subst.apply((0, types_2.getReturnType)(engine.subst.apply(staticType)));
|
|
505
|
+
if (ret.tag !== 'TCon' || ret.name !== witness.name || ret.args.length < witness.args.length)
|
|
506
|
+
return;
|
|
507
|
+
try {
|
|
508
|
+
for (let i = 0; i < witness.args.length; i++) {
|
|
509
|
+
engine.subst = engine.subst.compose((0, unify_1.unify)(engine.subst.apply(ret.args[i]), engine.subst.apply(witness.args[i])));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
catch (e) {
|
|
513
|
+
if (!(e instanceof unify_1.UnificationError))
|
|
514
|
+
throw e;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function inferTypeRepPropertyAccess(engine, node, resolved, propName, env) {
|
|
518
|
+
const innerType = resolved.args[0];
|
|
519
|
+
// Case 1: inner is a kv TCon (from .constructor on a kv-constrained value)
|
|
520
|
+
if (innerType.tag === 'TCon') {
|
|
521
|
+
const innerKv = (0, types_2.parseKvName)(innerType.name);
|
|
522
|
+
if (innerKv) {
|
|
523
|
+
const allNames = (0, expr_constraint_lookup_1.collectAllKvConstraintNames)(engine.kvConstraints, engine.kvConstructorConstraints, engine.subst, innerKv.varId, innerType.name);
|
|
524
|
+
if (allNames.length > 0) {
|
|
525
|
+
const result = (0, expr_constraint_lookup_1.lookupConstraintMethodOnTVar)(engine, innerKv.varId, propName, allNames, node);
|
|
526
|
+
if (result)
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
// Case 1b: inner is a concrete constructor (e.g. `TypeRep Array`,
|
|
532
|
+
// `TypeRep Either`). The witness IS that constructor, so static
|
|
533
|
+
// methods (`Array.of`, a sumtype's `.of`, …) resolve against the named
|
|
534
|
+
// type, and `.constructor` yields its constructor signature.
|
|
535
|
+
const staticResult = lookupStaticMethodByTypeName(engine, node, innerType.name, propName, true);
|
|
536
|
+
if (staticResult) {
|
|
537
|
+
bindStaticToWitness(engine, staticResult, innerType);
|
|
538
|
+
return staticResult;
|
|
539
|
+
}
|
|
540
|
+
if (propName === 'constructor') {
|
|
541
|
+
const ctorResult = inferTConConstructorAccess(engine, node, innerType, env);
|
|
542
|
+
if (ctorResult)
|
|
543
|
+
return ctorResult;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
// Case 2: inner is a TVar (from annotation like `TypeRep m`)
|
|
548
|
+
if (innerType.tag === 'TVar') {
|
|
549
|
+
const cNames = engine.kvConstraints.get(innerType.id);
|
|
550
|
+
if (cNames && cNames.length > 0) {
|
|
551
|
+
const result = (0, expr_constraint_lookup_1.lookupConstraintMethodOnTVar)(engine, innerType.id, propName, cNames, node);
|
|
552
|
+
if (result)
|
|
553
|
+
return result;
|
|
554
|
+
}
|
|
555
|
+
const appliedCNames = engine.kvConstructorConstraints.get(innerType.id);
|
|
556
|
+
if (appliedCNames && appliedCNames.length > 0) {
|
|
557
|
+
const result = (0, expr_constraint_lookup_1.lookupConstraintMethodOnTVar)(engine, innerType.id, propName, appliedCNames, node);
|
|
558
|
+
if (result)
|
|
559
|
+
return result;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
const trErr = (0, types_2.tVar)();
|
|
563
|
+
engine.recordNodeType(node.property, trErr);
|
|
564
|
+
return trErr;
|
|
565
|
+
}
|
|
566
|
+
/** Handle .constructor access on a concrete TCon (data types, env lookup). */
|
|
567
|
+
function inferTConConstructorAccess(engine, node, resolved, env) {
|
|
568
|
+
// For sumtype data types, build a synthetic constructor from the
|
|
569
|
+
// declaration's type vars. Checked BEFORE env.lookup because when
|
|
570
|
+
// the parent class shares the sumtype name, env.lookup would return
|
|
571
|
+
// the inferred class constructor which doesn't carry the correct
|
|
572
|
+
// return type for static method lookup.
|
|
573
|
+
if ((0, dataTypeRegistry_1.isDataType)(resolved.name)) {
|
|
574
|
+
const dt = (0, dataTypeRegistry_1.getDataType)(resolved.name);
|
|
575
|
+
// Sumtype `.constructor` is modelled as the union of its variant
|
|
576
|
+
// constructors (e.g. `Maybe`'s `.constructor` -> `Just a | Nothing`).
|
|
577
|
+
// This makes the available shapes immediately visible, lets static
|
|
578
|
+
// method lookup (`.of`) resolve through either branch, and yields a
|
|
579
|
+
// helpful `Just a | Nothing is not callable` diagnostic on `new`.
|
|
580
|
+
const args = dt.decl.typeVars.map(() => (0, types_2.tVar)());
|
|
581
|
+
const variantTypes = dt.decl.variants.map(v => {
|
|
582
|
+
const vArgs = v.fields.map(f => {
|
|
583
|
+
const idx = dt.decl.typeVars.indexOf(f);
|
|
584
|
+
return idx >= 0 ? args[idx] : (0, types_2.tVar)();
|
|
585
|
+
});
|
|
586
|
+
return (0, types_2.tCon)(v.name, vArgs);
|
|
587
|
+
});
|
|
588
|
+
const ctorType = (0, types_2.tUnion)(variantTypes);
|
|
589
|
+
engine.recordNodeType(node.property, ctorType);
|
|
590
|
+
// Stash the parent sumtype name so hover can surface
|
|
591
|
+
// `Just a | Nothing` next to the constructor type.
|
|
592
|
+
if (node.property.start !== undefined) {
|
|
593
|
+
engine.constructorParentSumtype.set(node.property.start, resolved.name);
|
|
594
|
+
// Freeze a pretty-printed snapshot of the union BEFORE any later
|
|
595
|
+
// unification (e.g. `new x.constructor(...)` failing) can poison
|
|
596
|
+
// its TVars to `$error`, so hover can still display `Just a | Nothing`.
|
|
597
|
+
engine.frozenPropertyTypeStr.set(node.property.start, (0, types_2.prettyTypeToString)(ctorType));
|
|
598
|
+
}
|
|
599
|
+
return ctorType;
|
|
600
|
+
}
|
|
601
|
+
// Arrow-factory binding (`const Pair = (a,b) => ({...})`): at runtime
|
|
602
|
+
// its instances' `.constructor` is `Object`, not the factory. Reflect
|
|
603
|
+
// that so `new p.constructor(...)` doesn't get typed as `Pair`.
|
|
604
|
+
if (engine.constructorProvenance.get(resolved.name) === 'arrow-factory') {
|
|
605
|
+
const ctorType = (0, types_2.tCon)('Object', []);
|
|
606
|
+
engine.recordNodeType(node.property, ctorType);
|
|
607
|
+
return ctorType;
|
|
608
|
+
}
|
|
609
|
+
// Built-in JS types (`Array`, `String`, `Number`, `Function`, …):
|
|
610
|
+
// synthesise a constructor signature that reflects the type's runtime
|
|
611
|
+
// constructor. For Array, the element type is taken from the receiver
|
|
612
|
+
// so `[a].constructor` is shaped `(..., Number | a) -> [a]`.
|
|
613
|
+
const builtinCtor = builtinConstructorType(resolved.name, resolved.args);
|
|
614
|
+
if (builtinCtor) {
|
|
615
|
+
engine.recordNodeType(node.property, builtinCtor);
|
|
616
|
+
if (node.property.start !== undefined) {
|
|
617
|
+
engine.builtinCtorKind.set(node.property.start, resolved.name);
|
|
618
|
+
}
|
|
619
|
+
return builtinCtor;
|
|
620
|
+
}
|
|
621
|
+
const ctorScheme = env.lookup(resolved.name);
|
|
622
|
+
if (ctorScheme) {
|
|
623
|
+
const ctorType = (0, env_1.instantiate)(ctorScheme);
|
|
624
|
+
engine.recordNodeType(node.property, ctorType);
|
|
625
|
+
return ctorType;
|
|
626
|
+
}
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
/** Handle static method lookup by identifier name (e.g. Box.fromPair). */
|
|
630
|
+
function inferStaticMethodAccess(engine, node, propName) {
|
|
631
|
+
const objName = node.object.name;
|
|
632
|
+
return lookupStaticMethodByTypeName(engine, node, objName, propName, false);
|
|
633
|
+
}
|
|
634
|
+
/** Handle static method lookup on TFun by return type. */
|
|
635
|
+
function inferFunStaticMethodAccess(engine, node, resolved, propName) {
|
|
636
|
+
const retType = engine.subst.apply((0, types_2.getReturnType)(resolved));
|
|
637
|
+
if (retType.tag !== 'TCon')
|
|
638
|
+
return null;
|
|
639
|
+
return lookupStaticMethodByTypeName(engine, node, retType.name, propName, true);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* `Function.prototype` methods on a TFun value. Unlike the generic
|
|
643
|
+
* `Function` TCon entries (which lose the return type), these preserve the
|
|
644
|
+
* function's own return type so that e.g. `({}).toString.call(x)` is
|
|
645
|
+
* typed `String` rather than a fresh TVar.
|
|
646
|
+
*/
|
|
647
|
+
function inferTFunBuiltinMethod(engine, node, resolved, propName) {
|
|
648
|
+
const retType = (0, types_2.getReturnType)(resolved);
|
|
649
|
+
let methodType = null;
|
|
650
|
+
switch (propName) {
|
|
651
|
+
case 'call':
|
|
652
|
+
// (thisArg, ...args) -> R — modelled as `a -> R` (this engine has no
|
|
653
|
+
// variadic; callers typically write `f.call(thisArg, …)` and only the
|
|
654
|
+
// return type matters for downstream inference).
|
|
655
|
+
methodType = (0, types_2.tFun)((0, types_2.tVar)('a'), retType);
|
|
656
|
+
break;
|
|
657
|
+
case 'apply':
|
|
658
|
+
// (thisArg, [args]) -> R — modelled as `a -> R`.
|
|
659
|
+
methodType = (0, types_2.tFun)((0, types_2.tVar)('a'), retType);
|
|
660
|
+
break;
|
|
661
|
+
case 'bind':
|
|
662
|
+
// (thisArg, ...args) -> sameFunction
|
|
663
|
+
methodType = (0, types_2.tFun)((0, types_2.tVar)('a'), resolved);
|
|
664
|
+
break;
|
|
665
|
+
case 'length':
|
|
666
|
+
methodType = types_2.tNumber;
|
|
667
|
+
break;
|
|
668
|
+
case 'name':
|
|
669
|
+
methodType = types_2.tString;
|
|
670
|
+
break;
|
|
671
|
+
case 'constructor': {
|
|
672
|
+
const ctor = builtinConstructorType('Function', []);
|
|
673
|
+
if (!ctor)
|
|
674
|
+
return null;
|
|
675
|
+
engine.recordNodeType(node.property, ctor);
|
|
676
|
+
if (node.property.start !== undefined) {
|
|
677
|
+
engine.builtinCtorKind.set(node.property.start, 'Function');
|
|
678
|
+
}
|
|
679
|
+
engine.methodSignatures.set(node.property.start, `Function.constructor :: ${(0, types_2.prettyTypeToString)(ctor)}`);
|
|
680
|
+
return ctor;
|
|
681
|
+
}
|
|
682
|
+
default:
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
engine.recordNodeType(node.property, methodType);
|
|
686
|
+
engine.methodSignatures.set(node.property.start, `Function.${propName} :: ${(0, types_2.prettyTypeToString)(methodType)}`);
|
|
687
|
+
return methodType;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Shared core: look up `propName` on `typeName` and record its instantiated
|
|
691
|
+
* type at the property node. When `requireStatic` is true, only entries
|
|
692
|
+
* marked `isStatic` are accepted.
|
|
693
|
+
*/
|
|
694
|
+
function lookupStaticMethodByTypeName(engine, node, typeName, propName, requireStatic) {
|
|
695
|
+
const entry = (0, methodRegistry_1.lookupMethod)(typeName, propName);
|
|
696
|
+
if (!entry || (requireStatic && !entry.isStatic))
|
|
697
|
+
return null;
|
|
698
|
+
const methodType = entry.scheme?.constraints?.length
|
|
699
|
+
? engine.instantiateWithConstraints(entry.scheme, node)
|
|
700
|
+
: entry.factory([]);
|
|
701
|
+
engine.recordNodeType(node.property, methodType);
|
|
702
|
+
engine.methodSignatures.set(node.property.start, `${typeName}.${propName} :: ${(0, types_2.prettyTypeToString)(methodType)}`);
|
|
703
|
+
return methodType;
|
|
704
|
+
}
|
|
705
|
+
/** Handle computed property access: arr[i], record["field"], etc. */
|
|
706
|
+
function inferComputedAccess(engine, node, env, objectType, resolved) {
|
|
707
|
+
const indexType = (0, expressions_1.inferExpression)(engine, node.property, env);
|
|
708
|
+
if (resolved.tag === 'TCon' && resolved.name === types_2.T_ARRAY && resolved.args.length === 1) {
|
|
709
|
+
engine.unifyWithDiagnostic(indexType, types_2.tNumber, node.property);
|
|
710
|
+
let elemType = resolved.args[0];
|
|
711
|
+
elemType = engine.maybeExpandAlias(elemType);
|
|
712
|
+
return elemType;
|
|
713
|
+
}
|
|
714
|
+
// Indexing an ABSTRACT constrained container (`xs[0]` with `xs :: f a`,
|
|
715
|
+
// `Functor f`): no constraint promises index access, so this is the same
|
|
716
|
+
// error as an unknown member (`xs.length`). Inside an Array guard the value
|
|
717
|
+
// is `[a]` (local `f ≡ Array`) and takes the Array case above.
|
|
718
|
+
if (resolved.tag === 'TCon') {
|
|
719
|
+
const kv = (0, types_2.parseKvName)(resolved.name);
|
|
720
|
+
if (kv && resolved.args.length > 0) {
|
|
721
|
+
const cNames = (0, expr_constraint_lookup_1.resolveKvConstraintNames)(engine.kvConstraints, engine.subst, kv.varId, resolved.name) ?? [];
|
|
722
|
+
if (cNames.length > 0) {
|
|
723
|
+
return recordPropertyError(engine, node.property, `Index access does not exist on constraint '${cNames.join(', ')}'`);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (resolved.tag === 'TVar') {
|
|
728
|
+
// If the index resolves to a String, treat the object as a record-like
|
|
729
|
+
// value (obj[stringKey]) and don't force-unify with Array. This avoids
|
|
730
|
+
// spurious "Cannot unify 'String' with 'Number'" diagnostics when the
|
|
731
|
+
// object's type is unknown.
|
|
732
|
+
const resolvedIndex = engine.subst.apply(indexType);
|
|
733
|
+
if (resolvedIndex.tag === 'TCon' && resolvedIndex.name === types_2.tString.name) {
|
|
734
|
+
return (0, types_2.tVar)();
|
|
735
|
+
}
|
|
736
|
+
// Index type not known yet either (`obj => key => obj[key]`, or a
|
|
737
|
+
// callback whose key is only fixed by a later argument, as in FP-library
|
|
738
|
+
// `foldMap (key => spec[key] …) (Object.keys (spec))`): committing the
|
|
739
|
+
// object to Array here rejected every record/dictionary argument later.
|
|
740
|
+
// Leave both open.
|
|
741
|
+
if (resolvedIndex.tag === 'TVar') {
|
|
742
|
+
return (0, types_2.tVar)();
|
|
743
|
+
}
|
|
744
|
+
const elemType = (0, types_2.tVar)();
|
|
745
|
+
engine.unifyWithDiagnostic(objectType, (0, types_2.tArray)(elemType), node.object);
|
|
746
|
+
engine.unifyWithDiagnostic(indexType, types_2.tNumber, node.property);
|
|
747
|
+
return engine.subst.apply(elemType);
|
|
748
|
+
}
|
|
749
|
+
if (resolved.tag === 'TRecord' && node.property.type === 'Literal' && typeof node.property.value === 'string') {
|
|
750
|
+
const key = node.property.value;
|
|
751
|
+
if (key in resolved.fields) {
|
|
752
|
+
const fieldType = resolved.fields[key];
|
|
753
|
+
engine.recordNodeType(node.property, fieldType);
|
|
754
|
+
return fieldType;
|
|
755
|
+
}
|
|
756
|
+
engine.addDiag(`Property '${key}' does not exist on type '${(0, types_2.typeToString)(resolved)}'`, node.property);
|
|
757
|
+
return (0, types_2.tVar)();
|
|
758
|
+
}
|
|
759
|
+
// Label-polymorphic record indexed by a non-literal key (e.g. inside
|
|
760
|
+
// `Object.keys(obj).reduce((acc, k) => obj[k]…)`). When the record
|
|
761
|
+
// carries a `{ [k] :: T }` group, the bracketed access yields `T` —
|
|
762
|
+
// bind the labelField's label-var to the index type if it's a TLabel
|
|
763
|
+
// var so subsequent unifications stay linked.
|
|
764
|
+
if (resolved.tag === 'TRecord' && resolved.labelFields && resolved.labelFields.length > 0) {
|
|
765
|
+
const resolvedIndex = engine.subst.apply(indexType);
|
|
766
|
+
// Only treat the index as a label when it's a String, a TLabel, or a TVar.
|
|
767
|
+
const indexLooksLikeKey = resolvedIndex.tag === 'TLabel' ||
|
|
768
|
+
(resolvedIndex.tag === 'TCon' && resolvedIndex.name === types_2.tString.name) ||
|
|
769
|
+
resolvedIndex.tag === 'TVar';
|
|
770
|
+
if (indexLooksLikeKey) {
|
|
771
|
+
const lf = resolved.labelFields[0];
|
|
772
|
+
// If the index is a TLabel-var, link it to this labelField's label.
|
|
773
|
+
if (resolvedIndex.tag === 'TLabel' && resolvedIndex.kind === 'var') {
|
|
774
|
+
try {
|
|
775
|
+
engine.unifyWithDiagnostic(resolvedIndex, lf.label, node.property);
|
|
776
|
+
}
|
|
777
|
+
catch { /* swallow */ }
|
|
778
|
+
}
|
|
779
|
+
return engine.subst.apply(lf.type);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
// A dictionary `Object k a` (also spelled with a concrete key type such as
|
|
783
|
+
// `Object String a`) indexed by a non-literal key yields its value type `a`
|
|
784
|
+
// — as for the label-record form above. Without this the lookup returned
|
|
785
|
+
// a fresh variable and every check on the result was lost (`handlers[name]
|
|
786
|
+
// (payload).bichain (f, g)` went unreported).
|
|
787
|
+
if ((0, types_1.isAppliedObject)(resolved)) {
|
|
788
|
+
const resolvedIndex = engine.subst.apply(indexType);
|
|
789
|
+
const indexLooksLikeKey = resolvedIndex.tag === 'TLabel' ||
|
|
790
|
+
(resolvedIndex.tag === 'TCon' && resolvedIndex.name === types_2.tString.name) ||
|
|
791
|
+
resolvedIndex.tag === 'TVar';
|
|
792
|
+
if (indexLooksLikeKey)
|
|
793
|
+
return engine.subst.apply(resolved.args[1]);
|
|
794
|
+
}
|
|
795
|
+
return (0, types_2.tVar)();
|
|
796
|
+
}
|
|
797
|
+
/** Handle instance method lookup on a TCon, including chain isolation for sumtype types. */
|
|
798
|
+
function inferTConInstanceMethod(engine, node, resolved, propName, entry, env) {
|
|
799
|
+
let methodArgs = resolved.args;
|
|
800
|
+
let displayType = resolved;
|
|
801
|
+
const isChainIsolated = node.object.type === 'CallExpression';
|
|
802
|
+
const dt = isChainIsolated && (0, dataTypeRegistry_1.isDataType)(resolved.name) ? (0, dataTypeRegistry_1.getDataType)(resolved.name) : null;
|
|
803
|
+
if (isChainIsolated) {
|
|
804
|
+
if (dt && dt.decl.typeVars.length > 0) {
|
|
805
|
+
methodArgs = resolved.args.map((arg, i) => {
|
|
806
|
+
const applied = engine.subst.apply(arg);
|
|
807
|
+
if (applied.tag === 'TVar')
|
|
808
|
+
return (0, types_2.tVar)(dt.decl.typeVars[i]);
|
|
809
|
+
return applied;
|
|
810
|
+
});
|
|
811
|
+
displayType = (0, types_2.tCon)(resolved.name, methodArgs);
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
const freshened = (0, typeUtils_1.freshenType)(resolved);
|
|
815
|
+
if (freshened.tag === 'TCon') {
|
|
816
|
+
methodArgs = freshened.args;
|
|
817
|
+
displayType = freshened;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
let methodType;
|
|
822
|
+
let constraintPreBindings = null;
|
|
823
|
+
if (entry.scheme?.constraints?.length && entry.receiverVarNames?.length) {
|
|
824
|
+
// Constrained instance methods (e.g. `Prop#eq :: Runnable a r => Prop t a ~> r -> Prop t a`):
|
|
825
|
+
// instantiate via the engine so pending constraints are registered with
|
|
826
|
+
// receiver type variables pre-bound to the actual container type
|
|
827
|
+
// arguments. This makes `id.eq("een")` (where `id :: Prop Tag Number`)
|
|
828
|
+
// detect that `String` does not satisfy `Runnable Number r`.
|
|
829
|
+
const preBindings = new Map();
|
|
830
|
+
for (let i = 0; i < entry.receiverVarNames.length && i < methodArgs.length; i++) {
|
|
831
|
+
const name = entry.receiverVarNames[i];
|
|
832
|
+
if (name)
|
|
833
|
+
preBindings.set(name, methodArgs[i]);
|
|
834
|
+
}
|
|
835
|
+
methodType = engine.instantiateWithConstraints(entry.scheme, node, undefined, false, preBindings);
|
|
836
|
+
constraintPreBindings = preBindings;
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
methodType = entry.factory(methodArgs);
|
|
840
|
+
}
|
|
841
|
+
// For sumtype chain isolation, disconnect receiver-position values in callback return types
|
|
842
|
+
if (isChainIsolated && (0, dataTypeRegistry_1.isDataType)(resolved.name) && methodType.tag === 'TFun') {
|
|
843
|
+
const callbackType = methodType.param;
|
|
844
|
+
if (callbackType.tag === 'TFun') {
|
|
845
|
+
const receiverVarIds = new Map();
|
|
846
|
+
const receiverConcreteStrings = new Map();
|
|
847
|
+
for (let i = 0; i < methodArgs.length; i++) {
|
|
848
|
+
const ma = methodArgs[i];
|
|
849
|
+
if (ma.tag === 'TVar') {
|
|
850
|
+
receiverVarIds.set(ma.id, dt.decl.typeVars[i] ?? ma.name);
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
receiverConcreteStrings.set((0, types_2.typeToString)(ma), dt.decl.typeVars[i] ?? 'a');
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
const replaceReceiverArgs = (t) => (0, typeUtils_1.mapType)(t, node => node.tag === 'TVar' && receiverVarIds.has(node.id) ? (0, types_2.tVar)(receiverVarIds.get(node.id)) :
|
|
857
|
+
node.tag === 'TCon' && receiverConcreteStrings.has((0, types_2.typeToString)(node)) ? (0, types_2.tVar)(receiverConcreteStrings.get((0, types_2.typeToString)(node))) :
|
|
858
|
+
undefined);
|
|
859
|
+
const freshenedReturn = replaceReceiverArgs(callbackType.result);
|
|
860
|
+
methodType = (0, types_2.tFun)((0, types_2.tFun)(callbackType.param, freshenedReturn), methodType.result);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
// sumtype variant property narrowing
|
|
864
|
+
if (node.object.type === 'ThisExpression' && (0, types_2.isUnion)(methodType)) {
|
|
865
|
+
methodType = (0, narrowing_1.narrowSumtypePropertyUnion)(methodType, resolved, methodArgs, env);
|
|
866
|
+
}
|
|
867
|
+
else if (node.object.type === 'Identifier' && (0, types_2.isUnion)(methodType)) {
|
|
868
|
+
const variantEnvKey = `__sumtypeVariant_${node.object.name}`;
|
|
869
|
+
methodType = (0, narrowing_1.narrowSumtypePropertyUnion)(methodType, resolved, methodArgs, env, variantEnvKey);
|
|
870
|
+
}
|
|
871
|
+
engine.recordNodeType(node.property, methodType);
|
|
872
|
+
// Build the hover signature. When the method has constraints (e.g.
|
|
873
|
+
// `Runnable String r =>`), prepend them with the receiver vars
|
|
874
|
+
// substituted by the actual container type arguments so the hover
|
|
875
|
+
// reflects the same constraints used during type-checking.
|
|
876
|
+
let constraintPrefix = '';
|
|
877
|
+
if (entry.scheme?.constraints?.length && constraintPreBindings) {
|
|
878
|
+
const substArg = (t) => (0, typeUtils_1.mapType)(t, n => (n.tag === 'TVar' && n.name && constraintPreBindings.has(n.name))
|
|
879
|
+
? constraintPreBindings.get(n.name)
|
|
880
|
+
: undefined);
|
|
881
|
+
const substConstraints = entry.scheme.constraints.map(c => ({
|
|
882
|
+
...c,
|
|
883
|
+
positionalArgs: c.positionalArgs?.map(substArg),
|
|
884
|
+
unionAlternatives: c.unionAlternatives?.map(substArg),
|
|
885
|
+
}));
|
|
886
|
+
// Render constraints via schemeToString using a sentinel TVar; strip
|
|
887
|
+
// the sentinel back off to get just the `C1, C2 => ` prefix.
|
|
888
|
+
const sentinelName = '__HOVER_CONSTRAINT_SENTINEL__';
|
|
889
|
+
const rendered = (0, types_2.schemeToString)({
|
|
890
|
+
vars: [],
|
|
891
|
+
type: (0, types_2.tVar)(sentinelName),
|
|
892
|
+
constraints: substConstraints,
|
|
893
|
+
});
|
|
894
|
+
const idx = rendered.lastIndexOf(sentinelName);
|
|
895
|
+
if (idx >= 0)
|
|
896
|
+
constraintPrefix = rendered.slice(0, idx);
|
|
897
|
+
}
|
|
898
|
+
engine.methodSignatures.set(node.property.start, engine.scrubSkolemString(`${resolved.name}#${propName} :: ${constraintPrefix}${(0, types_2.prettyTypeToString)(displayType)} ~> ${(0, types_2.prettyTypeToString)(methodType)}`));
|
|
899
|
+
return methodType;
|
|
900
|
+
}
|
|
901
|
+
/** Handle property access on a TVar: constraint methods, probe candidates.
|
|
902
|
+
* Returns null if no match found (caller falls through to later checks). */
|
|
903
|
+
function inferTVarPropertyAccess(engine, node, resolved, propName, objectType) {
|
|
904
|
+
const constraintNames = engine.kvConstraints.get(resolved.id);
|
|
905
|
+
const appliedNames = engine.kvConstructorConstraints.get(resolved.id);
|
|
906
|
+
const allNames = [...(constraintNames ?? []), ...(appliedNames ?? [])];
|
|
907
|
+
if (allNames.length > 0) {
|
|
908
|
+
if (propName === 'constructor') {
|
|
909
|
+
const typeRepType = (0, types_2.tCon)(types_2.T_TYPEREP, [resolved]);
|
|
910
|
+
engine.recordNodeType(node.property, typeRepType);
|
|
911
|
+
return typeRepType;
|
|
912
|
+
}
|
|
913
|
+
let isStaticMethod = false;
|
|
914
|
+
let isInstanceMethod = false;
|
|
915
|
+
let matchedConstraint = '';
|
|
916
|
+
let instanceMethodDef = null;
|
|
917
|
+
let instanceMethodReq = null;
|
|
918
|
+
for (const cName of allNames) {
|
|
919
|
+
const baseName = (0, types_2.constraintBaseName)(cName);
|
|
920
|
+
const def = (0, constraintRegistry_1.lookupConstraint)(baseName);
|
|
921
|
+
if (!def)
|
|
922
|
+
continue;
|
|
923
|
+
const effectiveMethods = (0, constraintRegistry_1.getEffectiveMethods)(baseName);
|
|
924
|
+
const req = effectiveMethods.find(m => m.name === propName);
|
|
925
|
+
if (req) {
|
|
926
|
+
if (req.signature.includes('~>')) {
|
|
927
|
+
isInstanceMethod = true;
|
|
928
|
+
matchedConstraint = baseName;
|
|
929
|
+
instanceMethodDef = def;
|
|
930
|
+
instanceMethodReq = req;
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
isStaticMethod = true;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (isStaticMethod) {
|
|
938
|
+
const varName = resolved.name || 'm';
|
|
939
|
+
return recordPropertyError(engine, node.property, `Cannot access constraint method '${propName}' on a bare type variable. Annotate the parameter as 'TypeRep ${varName}' to enable constructor method access.`);
|
|
940
|
+
}
|
|
941
|
+
if (isInstanceMethod && instanceMethodDef && instanceMethodReq) {
|
|
942
|
+
if (instanceMethodDef.expectedKind === '*') {
|
|
943
|
+
const methodType = (0, expr_constraint_lookup_1.lookupConstraintInstanceMethodOnTVar)(engine, resolved, propName, instanceMethodDef, instanceMethodReq, node);
|
|
944
|
+
if (methodType)
|
|
945
|
+
return methodType;
|
|
946
|
+
}
|
|
947
|
+
return recordPropertyError(engine, node.property, `'${propName}' is an instance method on constraint '${matchedConstraint}' and cannot be called on the type constructor`);
|
|
948
|
+
}
|
|
949
|
+
else {
|
|
950
|
+
const displayNames = allNames.map(n => (0, types_2.constraintBaseName)(n));
|
|
951
|
+
return recordPropertyError(engine, node.property, `Property '${propName}' does not exist on constraint '${displayNames.join(', ')}'`);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
// Probe all registered types for this property/method
|
|
955
|
+
const candidates = (0, methodRegistry_1.findMethodCandidates)(propName);
|
|
956
|
+
if (candidates.length === 1) {
|
|
957
|
+
const [typeName, entry] = candidates[0];
|
|
958
|
+
// Accessing a member must NOT nominally pin an otherwise-unconstrained
|
|
959
|
+
// receiver to the member's owner. A single registered owner — whether a
|
|
960
|
+
// BUILT-IN container (Array, String, …) OR a user-defined data type (e.g.
|
|
961
|
+
// `Pair` owning `fst`/`snd`) — is not sufficient evidence to coerce an
|
|
962
|
+
// unconstrained type variable into that type. Doing so mis-infers values
|
|
963
|
+
// whose real type is established elsewhere (annotations, chained
|
|
964
|
+
// declarations, `::rep`, or a later application): e.g. `pair.fst` /
|
|
965
|
+
// `pair.snd` in `map(pair => …)` must leave `pair` free rather than assume
|
|
966
|
+
// it is a `Pair` just because `Pair` happens to be the sole registered
|
|
967
|
+
// owner of `fst`/`snd`. Local annotations / chained declarations / `::rep`
|
|
968
|
+
// take precedence; the registry is consulted only when the receiver type is
|
|
969
|
+
// already known. Fall through so the caller records a suppressed property.
|
|
970
|
+
//
|
|
971
|
+
// EXCEPTION: container-IDENTITY methods (`Map#get`, `Set#add`) remain a
|
|
972
|
+
// strong enough signal to coerce. Unlike a plain accessor or a generic FP
|
|
973
|
+
// name, these operations are owned by essentially one container, so
|
|
974
|
+
// `x.get(k)` on an unknown `x` back-constrains `x` to `Map k v` (cascades
|
|
975
|
+
// so nested `.set`/`.has`/`.get` resolve and value types tie together).
|
|
976
|
+
if (!(0, methodRegistry_1.isContainerIdentityMethod)(typeName, propName)) {
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
const arity = (0, methodRegistry_1.getTypeArity)(typeName);
|
|
980
|
+
const freshArgs = (0, helpers_1.freshVars)(arity);
|
|
981
|
+
engine.unifyWithDiagnostic(objectType, (0, types_2.tCon)(typeName, freshArgs), node.object);
|
|
982
|
+
const resolvedArgs = freshArgs.map((a) => engine.subst.apply(a));
|
|
983
|
+
const methodType = entry.factory(resolvedArgs);
|
|
984
|
+
engine.recordNodeType(node.property, methodType);
|
|
985
|
+
const resolvedObj = engine.subst.apply(objectType);
|
|
986
|
+
engine.methodSignatures.set(node.property.start, `${typeName}#${propName} :: ${(0, types_2.prettyTypeToString)(resolvedObj)} ~> ${(0, types_2.prettyTypeToString)(methodType)}`);
|
|
987
|
+
return methodType;
|
|
988
|
+
}
|
|
989
|
+
// Several owners (e.g. `name` on Error, Function and a library's `Table`):
|
|
990
|
+
// no evidence either — the same rule as the single-owner case. The
|
|
991
|
+
// receiver stays free and the access is recorded as a record field. Even
|
|
992
|
+
// when every owner agrees on the member type (`String`), returning it
|
|
993
|
+
// without pinning the receiver typed `p => p.name` as `a -> String`, which
|
|
994
|
+
// rejected `{ name: null }` as the argument of a parameter callback.
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
// -----------------------------------------------------------------------
|
|
998
|
+
// Shared helpers for property-access error handling
|
|
999
|
+
// -----------------------------------------------------------------------
|
|
1000
|
+
/** Built-in JS properties that exist on all objects and should not trigger
|
|
1001
|
+
* "property does not exist" diagnostics. */
|
|
1002
|
+
function isBuiltInJsProperty(name) {
|
|
1003
|
+
return name === 'constructor' || name === 'toString' || name === 'valueOf';
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Object.prototype methods that are available on every JS object. Each
|
|
1007
|
+
* entry produces a freshly-constructed Type per access site so polymorphic
|
|
1008
|
+
* results (`valueOf :: () -> a`) get a fresh TVar each time and don't
|
|
1009
|
+
* accidentally unify across unrelated uses.
|
|
1010
|
+
*
|
|
1011
|
+
* Used by both inference (`o.toString` returns the right TFun) and
|
|
1012
|
+
* completion (`{}.` suggests these names).
|
|
1013
|
+
*/
|
|
1014
|
+
exports.OBJECT_PROTOTYPE_METHOD_NAMES = [
|
|
1015
|
+
'toString',
|
|
1016
|
+
'valueOf',
|
|
1017
|
+
'hasOwnProperty',
|
|
1018
|
+
'isPrototypeOf',
|
|
1019
|
+
'propertyIsEnumerable',
|
|
1020
|
+
];
|
|
1021
|
+
function objectPrototypeMethodType(name) {
|
|
1022
|
+
switch (name) {
|
|
1023
|
+
case 'toString': return (0, types_2.tFun)(types_2.tVoid, types_2.tString);
|
|
1024
|
+
case 'valueOf': return (0, types_2.tFun)(types_2.tVoid, (0, types_2.tVar)('a'));
|
|
1025
|
+
case 'hasOwnProperty': return (0, types_2.tFun)(types_2.tString, types_2.tBool);
|
|
1026
|
+
case 'isPrototypeOf': return (0, types_2.tFun)((0, types_2.tVar)('a'), types_2.tBool);
|
|
1027
|
+
case 'propertyIsEnumerable': return (0, types_2.tFun)(types_2.tString, types_2.tBool);
|
|
1028
|
+
case 'constructor': return builtinConstructorType('Object', []) ?? undefined;
|
|
1029
|
+
default: return undefined;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Constructor type for a built-in JS type. Returned by `.constructor`
|
|
1034
|
+
* accesses on values of these built-in types. For `Array`, the element
|
|
1035
|
+
* variable is taken from the receiver so `[a].constructor` is shaped
|
|
1036
|
+
* `(..., Number | a) -> [a]` (note: actual call-site widening to a union
|
|
1037
|
+
* of literal arg types is handled separately at the CallExpression level).
|
|
1038
|
+
*/
|
|
1039
|
+
function builtinConstructorType(typeName, typeArgs) {
|
|
1040
|
+
switch (typeName) {
|
|
1041
|
+
case 'Array': {
|
|
1042
|
+
const elem = typeArgs[0] ?? (0, types_2.tVar)('a');
|
|
1043
|
+
// Variadic shape: `(..., (Number | elem)) -> [elem]`. The spread
|
|
1044
|
+
// tuple holds a single union element which prints as `Number | a`.
|
|
1045
|
+
return (0, types_2.tFun)((0, types_2.tTuple)([types_2.tSpread, (0, types_2.tUnion)([types_2.tNumber, elem])]), (0, types_2.tArray)(elem));
|
|
1046
|
+
}
|
|
1047
|
+
case 'String': return (0, types_2.tFun)((0, types_2.tVar)('a'), types_2.tString);
|
|
1048
|
+
case 'Number': return (0, types_2.tFun)((0, types_2.tVar)('a'), types_2.tNumber);
|
|
1049
|
+
case 'Boolean': return (0, types_2.tFun)((0, types_2.tVar)('a'), types_2.tBool);
|
|
1050
|
+
case 'Object': return (0, types_2.tFun)((0, types_2.tVar)('a'), (0, types_2.tCon)('Object', []));
|
|
1051
|
+
case 'Date': {
|
|
1052
|
+
const date = (0, types_2.tCon)('Date', []);
|
|
1053
|
+
return (0, types_2.tUnion)([
|
|
1054
|
+
(0, types_2.tFun)(types_2.tVoid, date),
|
|
1055
|
+
(0, types_2.tFun)(types_2.tString, date),
|
|
1056
|
+
(0, types_2.tFun)((0, types_2.tTuple)([types_2.tSpread, types_2.tNumber]), date),
|
|
1057
|
+
]);
|
|
1058
|
+
}
|
|
1059
|
+
case 'RegExp':
|
|
1060
|
+
return (0, types_2.tFun)((0, types_2.tTuple)([types_2.tString, (0, types_2.tUnion)([types_2.tString, types_2.tUndefined])]), (0, types_2.tCon)('RegExp', []));
|
|
1061
|
+
case 'Error':
|
|
1062
|
+
case 'TypeError':
|
|
1063
|
+
case 'RangeError':
|
|
1064
|
+
case 'ReferenceError':
|
|
1065
|
+
case 'SyntaxError':
|
|
1066
|
+
return (0, types_2.tFun)((0, types_2.tUnion)([types_2.tString, types_2.tUndefined]), (0, types_2.tCon)(typeName, []));
|
|
1067
|
+
case 'Function':
|
|
1068
|
+
// Display fallback: `(..., String) -> Function`. Call-site smart-infer
|
|
1069
|
+
// can intercept via `engine.builtinCtorKind` to parse the body string
|
|
1070
|
+
// argument and synthesise a more precise function type.
|
|
1071
|
+
return (0, types_2.tFun)((0, types_2.tTuple)([types_2.tSpread, types_2.tString]), (0, types_2.tCon)('Function', []));
|
|
1072
|
+
default:
|
|
1073
|
+
return null;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Record a property-access error: stores `$error` as the node type, marks
|
|
1078
|
+
* the offset for hover suppression, emits a diagnostic, and returns the
|
|
1079
|
+
* error type so callers can `return` it directly.
|
|
1080
|
+
*/
|
|
1081
|
+
function recordPropertyError(engine, node, message) {
|
|
1082
|
+
const errType = (0, types_2.tCon)(types_2.T_ERROR, []);
|
|
1083
|
+
engine.recordNodeType(node, errType);
|
|
1084
|
+
engine.unconstrainedPropAccesses.add(node.start);
|
|
1085
|
+
engine.addDiag(message, node);
|
|
1086
|
+
return errType;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Record a suppressed property access (unconstrained TVar or wildcard).
|
|
1090
|
+
* Stores a fresh TVar as the node type and marks the offset for hover
|
|
1091
|
+
* suppression.
|
|
1092
|
+
*/
|
|
1093
|
+
function recordSuppressedProperty(engine, node) {
|
|
1094
|
+
const suppressed = (0, types_2.tVar)();
|
|
1095
|
+
engine.recordNodeType(node, suppressed);
|
|
1096
|
+
engine.unconstrainedPropAccesses.add(node.start);
|
|
1097
|
+
return suppressed;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Retry property accesses that were parked because their receiver was a bare
|
|
1101
|
+
* TVar at inference time. For every entry whose receiver has SINCE been
|
|
1102
|
+
* pinned to a concrete type (record / data type / builtin), look the member
|
|
1103
|
+
* up again and quietly unify the placeholder result var with the real member
|
|
1104
|
+
* type — resolving e.g. `lens :: [b]` to `[Number]` once `[String]` arrived
|
|
1105
|
+
* as the curried data argument. Entries whose receiver is still a TVar stay
|
|
1106
|
+
* parked (genuinely polymorphic parameters keep today's suppressed display).
|
|
1107
|
+
*
|
|
1108
|
+
* Called before a binding is generalized (so the resolved vars are not
|
|
1109
|
+
* spuriously quantified) and once more at end of inference as a catch-all.
|
|
1110
|
+
* Resolution is strictly additive: lookup misses and unification failures
|
|
1111
|
+
* are swallowed, preserving the previous silent behavior.
|
|
1112
|
+
*/
|
|
1113
|
+
function flushDeferredMemberAccesses(engine) {
|
|
1114
|
+
if (engine.deferredMemberAccesses.length === 0)
|
|
1115
|
+
return;
|
|
1116
|
+
const remaining = [];
|
|
1117
|
+
for (const entry of engine.deferredMemberAccesses) {
|
|
1118
|
+
const obj = engine.maybeExpandAlias(engine.subst.apply(entry.objType));
|
|
1119
|
+
if (obj.tag === 'TVar') {
|
|
1120
|
+
remaining.push(entry);
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
let memberType = null;
|
|
1124
|
+
if (obj.tag === 'TRecord' && entry.propName in obj.fields) {
|
|
1125
|
+
memberType = obj.fields[entry.propName];
|
|
1126
|
+
}
|
|
1127
|
+
else if (obj.tag === 'TCon' && obj.name !== types_2.T_UNION && obj.name !== types_2.T_ERROR) {
|
|
1128
|
+
const method = (0, methodRegistry_1.lookupMethod)(obj.name, entry.propName);
|
|
1129
|
+
if (method) {
|
|
1130
|
+
try {
|
|
1131
|
+
memberType = method.factory(obj.args);
|
|
1132
|
+
}
|
|
1133
|
+
catch {
|
|
1134
|
+
memberType = null;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
if (memberType) {
|
|
1139
|
+
try {
|
|
1140
|
+
const s = (0, unify_1.unify)(engine.resolve(memberType), engine.resolve(entry.resultType));
|
|
1141
|
+
engine.subst.mergeFrom(s);
|
|
1142
|
+
engine.unconstrainedPropAccesses.delete(entry.propStart);
|
|
1143
|
+
}
|
|
1144
|
+
catch (e) {
|
|
1145
|
+
if (!(e instanceof unify_1.UnificationError))
|
|
1146
|
+
throw e;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
// Concrete receiver — entry is consumed either way; a missing member
|
|
1150
|
+
// keeps the established silent (suppressed-hover) behavior.
|
|
1151
|
+
}
|
|
1152
|
+
engine.deferredMemberAccesses = remaining;
|
|
1153
|
+
}
|
|
1154
|
+
//# sourceMappingURL=expr-member.js.map
|