FunctionRef ignores the translator's `signature`: overloads are resolved from runtime values (null argument picks the last overload; Integer/Decimal mixed up in 3.x)
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- backend, testing-qa
調査の方向性
Start with src/elm/reusable.ts, where the issue says FunctionRef.exec resolves overloads and has a // TODO; inspect how FunctionRef.signature and function operand type specifiers are represented. Reproduce the three cases in the issue against the listed versions, then check for existing tests covering overload resolution. Done means signed calls select the declared overload, with runtime matching used only when the signature is absent, and the null case without a signature does not silently choose the last overload.
索引モデルが issue の本文から書いたものです。
説明
Summary
FunctionRef.exec resolves overloaded functions by matching the runtime values of the arguments against each overload's operand types and, when more than one overload remains, takes the last one (// TODO in src/elm/reusable.ts). The signature element that the translator emits on FunctionRef for overloaded functions is not used. As a result:
- A
nullargument matches every overload, so the last-declared overload is evaluated regardless of the argument's declared type. This gives a silently wrong result (or a downstream error) in 3.3.2 and 4.0.0-beta.1. - In 3.3.2, a JavaScript number matches both
IntegerandDecimal, soF(2)can run theDecimaloverload andF(2.0)theIntegeroverload, depending on declaration order. This part is fixed in 4.0.0-beta.1.
Reproduction
library OverloadResolution version '1.0.0'
define function "Scale"(x Integer): x * 2
define function "Scale"(x Decimal): x * 3
define function "Describe"(x Decimal): 'decimal'
define function "Describe"(x Integer): 'integer'
define IntegerArg: "Scale"(2)
define DecimalArgOtherOrder: "Describe"(2.0)
define NullDecimalArgOtherOrder: "Describe"(null as Decimal)
Translated with @cqframework/cql 5.8.0 (default signature level Overloads; every FunctionRef above carries a signature), evaluated with no data:
| Expression | Expected | cql-execution 3.3.2 | cql-execution 4.0.0-beta.1 |
|---|---|---|---|
IntegerArg |
4 | 6 | 4 |
DecimalArgOtherOrder |
'decimal' |
'integer' |
'decimal' |
NullDecimalArgOtherOrder |
'decimal' |
'integer' |
'integer' |
The JavaScript build of the reference engine (@cqframework/cql 5.8.0) returns the expected values for all three.
Specification
ELM schema, FunctionRef.signature (expression.xsd): "Specifies the declared signature of the function being called. If no signature is specified, the run-time types of the operands should be used to resolve any overload."
So run-time resolution is the fallback for ELM without a signature. When the signature is present, it identifies the overload that the translator resolved at compile time.
Suggested fix
When signature is present, select the FunctionDef whose operand type specifiers match the signature structurally (named, list, interval, choice and tuple specifiers). Use the current run-time matching only when signature is absent. For ELM translated without signatures, a null argument cannot discriminate between overloads; raising an ambiguity error would be safer than silently taking the last one.
Environment
The same resolution code (including the // TODO) is on master at e87e3fa (src/elm/reusable.ts).
cql-execution 3.3.2 and 4.0.0-beta.1, Node 24, Windows 11, TZ=UTC, translator @cqframework/cql 5.8.0.
- 主要言語
- JavaScript
- スター
- 86
- フォーク
- 40
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cqframework/cql-execution のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cqframework/cql-execution#410 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cqframework/cql-execution#407 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
cqframework/cql-execution#406 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 54/100
cqframework/cql-execution#415 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
cqframework/cql-execution#414 ·
cqframework/cql-execution の issue をすべて見る
似ている issue
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount due対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
verified whatsapp
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 6 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信