lean4-htt/tests/lean/run/hexnum.lean
Rob23oba b7ea66d8d3
fix: consider underscores in getHexNumSize (#10719)
This PR fixes `getHexNumSize` to consider underscores. Previously, only
the amount of bytes was counted, making it output 9 for `1234_abcd`
instead of the actual number of digits, which is 8.
2025-10-16 13:57:58 +00:00

28 lines
511 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax "#" noWs hexnum : term
open Lean in
macro_rules
| `(#$n:hexnum) => `(($(quote n.getHexNumSize), $(quote n.getHexNumVal)))
/-- info: (4, 44733) : Nat × Nat -/
#guard_msgs in
#check #aebd
/-- info: (1, 10) : Nat × Nat -/
#guard_msgs in
#check #a
/-- info: (2, 16) : Nat × Nat -/
#guard_msgs in
#check #10
/-- info: (2, 5) : Nat × Nat -/
#guard_msgs in
#check #05
/-- info: (3, 10) : Nat × Nat -/
#guard_msgs in
#check #00a
/-- info: (8, 65536) : Nat × Nat -/
#guard_msgs in
#check #0001_0000