Order of operations in integer arithmetic is wrong

オープン
#976 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp
領域
compilers

調査の方向性

まず Ink で3つの算術例を再現し、演算子の優先順位を担う parser または evaluator のエントリーポイントを追跡してください。issue にはファイルもテストも指定されていません。乗算と除算が期待される左から右への動作に従い、既存の Ink スクリプトへの互換性の影響が考慮され、報告された式が検証されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Reproduce
{ 10 * 8 / 10 }

Expected Output
8

Observed Output
0

Workaround
{ (10 * 8) / 10 }

I'd expect the order of operations to go left to right, as is generally the case with other environments/programming languages. Unfortunately, fixing this might break existing Ink scripts that rely on this behavior. Also unfortunately, there's probably a lot of scripts out in the while that have bugs in them because of this bug.

Addendum
Looking at the following examples, it seems that the problem is that division has a higher priority than multiplication, which it shouldn't:

  • Forcing right-to-left evaluation: { 10 / (2 * 2) } -> 2
  • Forcing left-to-right evaluation: { (10 / 2) * 2 } -> 10
  • Without brackets: { 10 / 2 * 2 } -> 10
主要言語
C#
スター
5k
フォーク
550
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

inkle/ink のほかの issue

inkle/ink の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。