aiscript
aiscript copied to clipboard
🔋 A lightweight scripting language runing on JavaScript
Bumps the gh-actions group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [actions/setup-node](https://github.com/actions/setup-node). Updates `actions/checkout` from 6.0.0 to 6.0.1 Release notes Sourced from actions/checkout's releases. v6.0.1 What's Changed Update...
Bumps the npm-deps group with 12 updates in the / directory: | Package | From | To | | --- | --- | --- | | [uuid](https://github.com/uuidjs/uuid) | `11.1.0` |...
# What `visitNode`によってASTの`Break['expr']`, `NamedTypeSource['inner']`, `FnTypeSource['result']`の内容が走査されるようになります。 これらの場所における不正な変数名、return文、break文、continue文、型注釈がある場合に文法エラーが発生するようになります。 # Why Fixes #999 Fixes #1000 # Additional info (optional) テストにおいて`expect.hasAssertion()`が上手く機能しなかったので、`test/testutils.ts`の`eq`関数の実装を変えて、`assert`でなくVitestの`expect`を使用するように変更しています。
https://github.com/aiscript-dev/aiscript/pull/1003#issuecomment-3616380821
``` { a: print(1) a: print(2) } ``` 上記のコードにおいて、`2`のみが出力されます。
``` @f(x: T) {} ``` `T`が`str`だとすると、`str`という不正な型を意味してしまうため、 これはエラーになってほしい。 プレイグラウンド: https://aiscript-dev.github.io/ja/playground.html#N4Igxg9gJgpiBcIACAzAPAFQHwAoAe8ABBmgHYCuAtlgJSHAC+IANCAG4wBOAzgJYSkEIAIwA6AEyiADCAZA
# What 関数の型注釈の名前が重複した場合に発生するエラーを`Error`から`AiScriptSyntaxError`に変更します。 また、関数の引数や返り値の型注釈がない場合であっても型引数の名前が重複した際のエラーが発生するようにします。 # Why Fixes #997 Fixes #998 # Additional info (optional)
`visitNode` は 関数型の返り値の部分に対しても呼び出されるべきですが、そのようになっていません https://github.com/aiscript-dev/aiscript/blob/2f103d2d639704b7012763503272ec9d2144f54b/src/parser/visit.ts#L211-L216 そのため、返り値の型を関数にして型引数に未使用の予約語を入れると、その型引数を使ってもエラーが発生しません ## 例 ``` let x: @() => @() => async = @() {} ``` [Playground](https://aiscript-dev.github.io/ja/playground.html#N4Igxg9gJgpiBcIA2MAuACAHvdABAFAJToC8AfHgDwCGAzgJ4B2YZRpFdTYpebwAvgB1GIADQgAbjABOtAJYQRiAIwA6AEyqADCH5A)
`visitNode` はノードの持っている全ての子ノードに対して呼び出されるべきですが、 式を持つことがある `break` は無視されています ## 例 ``` #label: eval { break #label eval { let async = 1 async } } ``` [Playground](https://aiscript-dev.github.io/ja/playground.html#N4Igxg9gJgpiBcIDEAbAhgIxi+ACGAbmirsADoB2uuGATjGgNa6qbb5EnlXW4owAXXGgDOATwphcAXlwBGSr2HjJi3AF9K6kABoQBGLREBLCBQQg5AOgBMVgAwh1QA)
関数の式で引数や返り値の型注釈がない場合、型引数に同じ名前が使われていてもエラーが発生しない ## 例 ``` @() {} ``` [Playground](https://aiscript-dev.github.io/ja/playground.html#N4Igxg9gJgpiBcIACAeAKgGgARoHwAoBKLYAXxAxADcYAnAZwEsIA7BEARgDoAmLgBhCkgA)