Phase 4: float literals in generated Rust tables (const-context fix)

In a const context an integer literal does not infer as f64 (E0308),
so the generator emits float literals (100000.0) for PropDef::r lo/hi
via a new fmt_f64 helper, and the combined StockChart table is a named
const (STOCK_CHART_PROPS) -- an inline &[...] of const-fn calls is not
promotable to &'static (E0515). tools/gen_phase4_props.py gains
fmt_f64 (rust mode only; the C++ mode keeps integer bounds).
This commit is contained in:
cnmcdee committed 2026-11-30 14:48:33 +00:00
1 parent 786f1dd428
commit 8bbc094c62
2 files changed
+361 -348

No files matched your search

File diff suppressed because it is too large. Load diff
+7 -1
View File
@@ -20,6 +20,12 @@ def fmt_num(v):
s = ("%.10f" % v).rstrip("0").rstrip(".")
return s if s else "0"
def fmt_f64(v):
# Rust float literal: in a const context an integer literal does NOT
# infer as f64 (E0308), so always emit a '.' (e.g. 100000.0, 0.01).
s = fmt_num(v)
return s if ("." in s or "e" in s) else s + ".0"
def srgb_to_rgb(init):
m = re.match(r"(?:Srgb)?\{([^}]*)\}", init)
if not m: return None
@@ -370,7 +376,7 @@ def main():
out.append(' PropDef::n("%s", K::%s, "%s"),' % (prop, kind, default))
else:
out.append(' PropDef::r("%s", K::%s, "%s", %s, %s),' % (
prop, kind, default, fmt_num(lo), fmt_num(hi)))
prop, kind, default, fmt_f64(lo), fmt_f64(hi)))
out.append("];")
out.append("// Dispatch arms (exact XFrame class names) for props_for's match.")
for w in sorted(all_props):