Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 8 additions & 2 deletions test/types.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -108,6 +108,12 @@ describe('generics', () => {
@f<>() {}
`));
});

test.concurrent('cannot have inner type', async () => {
await expect(() => exe(`
@f<T>(v: T<num>) {}
`)).rejects.toThrow(AiScriptSyntaxError);
});
});
});

Expand Down
1 change: 1 addition & 0 deletions unreleased/fix-type-param-inner-type-is-allowed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix: 型引数で定義された型に型引数を与えてもエラーが発生しない問題を修正
Loading