From 53b18e14ba00ae7a0ddc08ce2d83b9736e8e9e14 Mon Sep 17 00:00:00 2001 From: takejohn Date: Fri, 5 Dec 2025 23:41:30 +0900 Subject: [PATCH] =?UTF-8?q?=E5=9E=8B=E5=BC=95=E6=95=B0=E3=81=A7=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9=E3=81=95=E3=82=8C=E3=81=9F=E5=9E=8B=E3=81=AB=E5=9E=8B?= =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E4=B8=8E=E3=81=88=E3=81=A6=E3=82=82?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/type.ts | 2 +- test/types.ts | 10 ++++++++-- unreleased/fix-type-param-inner-type-is-allowed.md | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 unreleased/fix-type-param-inner-type-is-allowed.md 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: 型引数で定義された型に型引数を与えてもエラーが発生しない問題を修正