Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Untagged variant accepts @as number literals that are the same JavaScript number

未關閉 適合新手
#8,953 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
77/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript
領域
compilers

研究方向

閱讀 compiler/ml/UntaggedVariants.md 中的規則 6 及其測試,接著追蹤依書寫形式比較字面值的重複字面值檢查。根據 JavaScript 執行時的值,檢查 1 和 1.0、1 和 4294967297 等情況。完成標準是:等效的 JavaScript 值會被視為重複的 @as 案例而遭拒,且測試涵蓋這些範例。

由索引模型根據 Issue 內容生成。

描述

An untagged variant accepts two @as number literals that are the same JavaScript number, when they are spelled differently.

@unboxed type t = | @as(1) A | @as(1.0) B
let name = v => switch v { | A => "A" | B => "B" }
@inline(never) let id = x => x
Console.log2(name(B), name(id(B)))

Output: B A. B is the number 1 at run time, so a dispatched B matches A, while the folded name(B) returns "B".

The same holds for @as(1) A | @as(4294967297) B, because int literals are emitted as 32-bit: name(id(B)) returns "A".

Expected: the declaration is rejected, as for two @as(1) cases, because the literals are equal as JavaScript values.

The duplicate-literal check compares literals by spelling. The rule and its tests are in compiler/ml/UntaggedVariants.md (rule 6), in #8952.

主要語言
OCaml
星號
7.5k
分支
483
平均合併
1 天 1 小時
30 天內合併 PR
169

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

rescript-lang/rescript 的其他 Issue

查看 rescript-lang/rescript 的全部 Issue

相似的 Issue

更多 Compilers Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。