aiscript icon indicating copy to clipboard operation
aiscript copied to clipboard

fix: 型引数名の重複に関するエラーが適切に発生しない問題を修正

Open takejohn opened this issue 3 weeks ago • 3 comments

What

関数の型注釈の名前が重複した場合に発生するエラーをErrorからAiScriptSyntaxErrorに変更します。 また、関数の引数や返り値の型注釈がない場合であっても型引数の名前が重複した際のエラーが発生するようにします。

Why

Fixes #997 Fixes #998

Additional info (optional)

takejohn avatar Dec 05 '25 10:12 takejohn

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Files with missing lines Coverage Δ
src/parser/plugins/validate-type.ts 100.00% <100.00%> (ø)
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov-commenter avatar Dec 05 '25 10:12 codecov-commenter

型に関するエラーは TypeSourceType に変換する部分にもあり、そこでは AiScriptSyntaxError が使われているので、 AiScriptTypeError という名前は適切ではないように思います

https://github.com/aiscript-dev/aiscript/blob/2f103d2d639704b7012763503272ec9d2144f54b/src/type.ts#L202

TypeParam にも loc を持たせて、問題の箇所でも AiScriptSyntaxError を投げるようにするのが親切なのではないかと思います

poppingmoon avatar Dec 05 '25 10:12 poppingmoon

@poppingmoon コメントありがとうございます 🙏

型に関するエラーは TypeSourceType に変換する部分にもあり、そこでは AiScriptSyntaxError が使われているので、 AiScriptTypeError という名前は適切ではないように思います

AiScriptSyntaxErrorに変更しました。

TypeParam にも loc を持たせて、

これはバグ修正だけでなく機能追加(APIの変更)の面もあるので次のマイナーリリースで検討したいと思います。

takejohn avatar Dec 05 '25 12:12 takejohn