can1357/oh-my-pi · error · OmpTypeError
alias "${entry.name}" is not generic
Error message
alias "${entry.name}" is not generic What it means
When a scope resolves a reference to an alias that was declared without generic parameters, but the resolution machinery expects it to be a runtime generic (i.e., the reference uses generic instantiation syntax), omptype throws. The alias has no `genericParameters`, so it cannot be instantiated with type arguments.
Source
Thrown at packages/omptype/src/type.ts:3865
const reference: IR = {
k: "alias",
name,
resolve: () => {
const target = targets.get(name);
if (target !== undefined) return target;
const parsed = parseDef(definition, resolve);
targets.set(name, parsed);
return parsed;
},
};
references.set(name, reference);
return reference;
}) as AliasResolver;
const genericFor = (entry: ScopeAlias): RuntimeGeneric => {
if (entry.generic !== undefined) return entry.generic;
const parameters = entry.genericParameters;
if (parameters === undefined) throw new OmpTypeError(`alias "${entry.name}" is not generic`);
entry.generic = createRuntimeGeneric(parameters, entry.definition, resolve, false);
return entry.generic;
};
const genericInstantiations = new Map<string, IR>();
resolve.hasGeneric = name => entries.get(name)?.genericParameters !== undefined;
resolve.generic = (name, arguments_) => {
const entry = entries.get(name);
if (entry === undefined || entry.genericParameters === undefined) return undefined;
const key = `${name}<${arguments_.map(expectedOf).join(",")}>`;
const existing = genericInstantiations.get(key);
if (existing !== undefined) return existing;
let target: IR | undefined;
const reference: IR = {
k: "alias",
name: key,
resolve: () => {
target ??= genericFor(entry)[GENERIC_META].instantiateIR(arguments_);
return target;View on GitHub (pinned to 9690622007)
Solutions
- Remove the `<...>` arguments from the reference: use `"box"` instead of `"box<string>"`.
- Make the alias generic by declaring parameters: `{ "box<T>": { value: "T" } }`.
- Grep the scope definitions for instantiation syntax on the named alias and fix all call sites.
Example fix
// before
type.scope({ "box": { value: "string" }, "use": "box<string>" })
// after
type.scope({ "box": { value: "string" }, "use": "box" }) Defensive patterns
Strategy: validation
Validate before calling
const isGenericRef = (def: string) => /\w+<.+>/.test(def); // if true, the referenced alias must be declared with <T> parameters
Try / catch
try { const $ = type.scope(defs); } catch (e) { if (e instanceof OmpTypeError && e.message.includes('is not generic')) removeInstantiationArgs(e.message); else throw e; } Prevention
- Whenever you de-generalize an alias, search the scope for '<...>' references to it
- Declare generic aliases as "name<T>" keys in the scope
- Keep scope alias declarations and their references in the same module so refactors touch both
When it happens
Trigger: Referencing an alias with generic arguments inside a scope while the alias definition itself declares no parameters, e.g. scope `{ box: { value: "string" }, use: "box<string>" }` — `box` is not generic.
Common situations: Renaming/rewriting a generic alias to a concrete one but forgetting to update call sites that still use `<...>` instantiation; copying a reference from another scope where the alias was generic.
Related errors
- alias "${name}" is declared as both public and private
- unknown alias "${name}"
- invalid generic parameter "${parameter.name}"
- duplicate generic parameter "${parameter.name}"
- generic declarations require at least one parameter
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/26a4a9fb88a06a82.
Report an issue: GitHub.