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

  1. Remove the `<...>` arguments from the reference: use `"box"` instead of `"box<string>"`.
  2. Make the alias generic by declaring parameters: `{ "box<T>": { value: "T" } }`.
  3. 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

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


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/26a4a9fb88a06a82. Report an issue: GitHub.