aiscript-dev / aiscript

🔋 A lightweight scripting language runing on JavaScript
https://aiscript-dev.github.io/aiscript/
MIT License
186 stars 33 forks source link

Scannerで一部の文字が無視される #766

Closed poppingmoon closed 1 month ago

poppingmoon commented 1 month ago

##, |, & のいずれかの後に数字やアルファベットが続くとき、記号部分が無視される

実行例

<: ##1    // 1
<: |0.2   // 0.2
<: &null  // null
FineArchs commented 1 month ago

どのような環境で実行しましたか?私の手元の環境では再現できないのですが…

poppingmoon commented 1 month ago

https://aiscript-dev.github.io/aiscript/ です

FineArchs commented 1 month ago

確認できました。開発版の方のパーサーの問題ですね。

本来ならパーサーエラーで弾くべきですが、普通は書かない文であり、放っておいても問題はなさそうな気もします。

FineArchs commented 1 month ago

ちなみに、どのような状況でこのバグを発見したかを聞いてもいいですか?

poppingmoon commented 1 month ago

https://github.com/aiscript-dev/aiscript/blob/master/src/parser/scanner.ts を読んでいるときに気づきました

FineArchs commented 1 month ago

確認した所、readToken()の記号トークンのswitch caseの一部に変数tokenを更新しない場合があるものがあり、それが今回のバグに繋がっているようですね。

修正は容易そうですし、今後の安全性のために直したほうがよさそうですね。

FineArchs commented 1 month ago

done in #769