diff --git a/src/type.ts b/src/type.ts index 4f2d6e61..97b28746 100644 --- a/src/type.ts +++ b/src/type.ts @@ -168,7 +168,7 @@ export function getTypeNameBySource(typeSource: Ast.TypeSource): string { export function getTypeBySource(typeSource: Ast.TypeSource, typeParams?: readonly Ast.TypeParam[]): Type { if (typeSource.type === 'namedTypeSource') { const typeParam = typeParams?.find((param) => param.name === typeSource.name); - if (typeParam != null) { + if (typeParam != null && typeSource.inner == null) { return T_PARAM(typeParam.name); } diff --git a/test/types.ts b/test/types.ts index d876e00a..e0e4b2e4 100644 --- a/test/types.ts +++ b/test/types.ts @@ -1,8 +1,8 @@ import * as assert from 'assert'; -import { describe, test } from 'vitest'; +import { describe, expect, test } from 'vitest'; import { utils } from '../src'; import { NUM, STR, NULL, ARR, OBJ, BOOL, TRUE, FALSE, ERROR ,FN_NATIVE } from '../src/interpreter/value'; -import { AiScriptRuntimeError } from '../src/error'; +import { AiScriptRuntimeError, AiScriptSyntaxError } from '../src/error'; import { exe, getMeta, eq } from './testutils'; describe('function types', () => { @@ -108,6 +108,12 @@ describe('generics', () => { @f<>() {} `)); }); + + test.concurrent('cannot have inner type', async () => { + await expect(() => exe(` + @f(v: T) {} + `)).rejects.toThrow(AiScriptSyntaxError); + }); }); }); diff --git a/unreleased/fix-type-param-inner-type-is-allowed.md b/unreleased/fix-type-param-inner-type-is-allowed.md new file mode 100644 index 00000000..5dc602d1 --- /dev/null +++ b/unreleased/fix-type-param-inner-type-is-allowed.md @@ -0,0 +1 @@ +- Fix: 型引数で定義された型に型引数を与えてもエラーが発生しない問題を修正