lean4-htt/tests/compiler/str.lean
Rob23oba fad0e69cc7
fix: make name mangling unambiguous (#10727)
This PR fixes name mangling to be unambiguous / injective by adding `00`
for disambiguation where necessary. Additionally, the inverse function,
`Lean.Name.unmangle` has been added which can be used to unmangle a
mangled identifier. This unmangler has been added to demonstrate the
injectivity but also to allow unmangling identifiers e.g. for debugging
purposes.

Closes #10724
2025-10-23 07:18:07 +00:00

31 lines
1.1 KiB
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.

def main : IO Unit := pure () /- -- TODO: remove after stage0 update
def showChars : Nat → String → String.Pos.Raw → IO Unit
| 0, _, _ => pure ()
| n+1, s, idx => do
unless s.atEnd idx do
IO.println (">> " ++ toString (s.get idx)) *>
showChars n s (s.next idx)
def main : IO UInt32 :=
let s₁ := "hello α_world_β";
let b : String.Pos.Raw := 0;
let e := s₁.rawEndPos;
IO.println (s₁.extract b e) *>
IO.println (s₁.extract (b+ " ") e) *>
IO.println (s₁.extract (b+ " ") (e.unoffsetBy ⟨1⟩)) *>
IO.println (s₁.extract (b.offsetBy ⟨2⟩) (e.unoffsetBy ⟨2⟩)) *>
IO.println (s₁.extract (b.offsetBy ⟨7⟩) e) *>
IO.println (s₁.extract (b.offsetBy ⟨8⟩) e) *>
IO.println (toString e) *>
IO.println (repr " aaa ".trim) *>
showChars s₁.length s₁ 0 *>
IO.println ("abc".isPrefixOf "abcd") *>
IO.println ("abcd".isPrefixOf "abcd") *>
IO.println ("".isPrefixOf "abcd") *>
IO.println ("".isPrefixOf "") *>
IO.println ("ab".isPrefixOf "cb") *>
IO.println ("ab".isPrefixOf "a") *>
IO.println ("αb".isPrefixOf "αbc") *>
IO.println ("\x00a").length *>
pure 0
-/