InternalCompilerException: Expr.Binary operator not recognized when a math-name operator is used infix

オープン 初心者向け
#13,765 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
領域
compilers

調査の方向性

Weeder2.visitBinaryExprから始めます。issueによると、ここではNameMathが内部エラーに至ります。このケースを既存のGenericOperatorの処理および#13326にある#13320の修正と比較してください。a ⊆ bと、提示されたユーザー定義演算子の例で再現し、その後、どちらも内部エラーではなく期待される適用または診断を生成することを確認してください。

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

説明

bug

Summary

Using a math-name operator such as ⊆ in infix position makes the compiler throw InternalCompilerException: Expr.Binary operator not recognized. The parser accepts the expression (Parser2 treats NameMath as a binary operator, with the precedence of UserDefinedOperator), but Weeder2.visitBinaryExpr has no case for the NameMath token and falls through to the final throw.

This is the same exception as in #13320, which was fixed for a keyword between backticks (#13326). The input below is a different trigger and still crashes.

Minimal reproduction

Create Hello.flix:

def f(a: Bool, b: Bool): Bool = a ⊆ b

Run:

java -jar flix.jar --version
java -jar flix.jar check Hello.flix
echo "exit $?"

Actual behavior

Output (first lines; Flix 0.79.0, 0.80.0 and a master build at 2f6ce4aff157071d4f88ab9361b5887c920b2551 print the same message):

#
# An unexpected error has been detected by the Flix compiler:
#
#   Expr.Binary operator not recognized (Hello.flix:1:33)
#

The compiler exits with code 1 and writes crash_report_0.txt. The exception is thrown at Weeder2$Exprs$.visitBinaryExpr. a ∪ b behaves the same.

The same happens for a user-defined operator that is defined and used:

def ⊆(x: Bool, y: Bool): Bool = x and y

def main(): Bool = true ⊆ false
#
# An unexpected error has been detected by the Flix compiler:
#
#   Expr.Binary operator not recognized (Hello.flix:3:20)
#

Expected behavior

A diagnostic instead of an internal error, or an application of the function named ⊆ (as for GenericOperator, which visitBinaryExpr turns into Expr.Apply(Expr.Ambiguous(...))).

Environment

  • Flix 0.80.0 (java -jar flix.jar --version: The Flix Programming Language 0.80.0), master 2f6ce4aff157071d4f88ab9361b5887c920b2551, 0.79.0
  • JDK: Eclipse Temurin 21.0.13+9
  • OS: Linux 7.2.12, aarch64
主要言語
Flix
スター
2.7k
フォーク
194
平均マージ
10時間 7分
マージ済み PR(30日)
170

環境構築

はじめの一歩

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

flix/flix のほかの issue

flix/flix の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

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

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