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)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- backend, testing-qa
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 86
- Fork
- 40
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cqframework/cql-execution
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cqframework/cql-execution#410 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cqframework/cql-execution#407 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
cqframework/cql-execution#406 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
cqframework/cql-execution#415 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
cqframework/cql-execution#414 ·
Tất cả issue của cqframework/cql-execution
Issue tương tự
-
verified whatsapp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
salesforce/sa11y#1022 ·
-
[ordering-review] workshop order graph: 1 minor ordering issue, 3 cycles are false positivesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
githubnext/gh-aw-workshop#6379 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
FEATURE REQUEST
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
linuxmint/cinnamon-spices-applets#9386 ·
Maintainer thường phản hồi trong vòng 1 ngày