MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / checkArity

Function checkArity

src/compute-engine/boxed-expression/validate.ts:65–100  ·  view source on GitHub ↗
(
  ce: ComputeEngine,
  ops: ReadonlyArray<Expression>,
  count: number
)

Source from the content-addressed store, hash-verified

63import {
64 activeRollbackFrame,
65 repairsForbiddenByRollbackFrame,
66} from '../inference-rollback.js';
67import { fuzzyStringMatch } from '../../common/fuzzy-string-match.js';
68import { isOperatorDef, isValueDef } from './utils.js';
69import { isTensorValue } from './tensor-view.js';
70import { _BoxedOperatorDefinition } from './boxed-operator-definition.js';
71import {
72 isSymbol,
73 isFunction,
74 isString,
75 isContinuationOperand,
76 containsContinuationOperand,
77} from './type-guards.js';
78import { narrowStringLiteralToCharacter } from './boxed-character.js';
79
80// Parsed once: the type of an indexed collection whose every element is a
81// number. Used in `checkNumericArgs` to accept collections for broadcasting on
82// the strength of their static element type.
83const INDEXED_COLLECTION_OF_NUMBER = parseType('indexed_collection<number>');
84
85// `typeCouldBeNumericCollection` / `typeCouldBeNumericTuple` — the COULD-
86// semantics predicates `checkNumericArgs` uses to admit collection/tuple
87// operands — are imported from `collection-utils.ts`, where the
88// `Add`/`Multiply` type handlers and the invisible-operator gate share the
89// SAME predicates. Keeping a private copy here let the two layers diverge:
90// an operand admitted by validation but missed by the type handlers
91// collapsed to `number` and baked `incompatible-type` (Tycho item 30).
92
93// `couldBeUnkeyedCollectionOperand` moved to `collection-utils.ts` alongside
94// the sibling COULD-semantics predicates, so validation, overload resolution
95// and result typing share ONE definition — a private copy here would let the
96// resolution used for validation admit different arms from the one used for
97// result typing.
98
99/**
100 * Exclusion gate for scalar numeric INFERENCE — deliberately WIDER than
101 * broadcast admission (`couldBeUnkeyedCollectionOperand`). The hazard the
102 * gate prevents is keyedness-independent: `x._infer('real')` on an operand
103 * whose inferred result signature is collection-shaped WIDENS the shared

Callers 5

collections.tsFile · 0.90
canonicalMatrixFunction · 0.90
core.tsFile · 0.90
trigonometry.tsFile · 0.90
trigFunctionFunction · 0.90

Calls 4

flattenFunction · 0.90
errorMethod · 0.65
sliceMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected