Fix python name clash printing again, for non-ascii

This commit is contained in:
Louis Gesbert 2024-04-05 15:25:46 +02:00
parent f71db385d5
commit 8ae9701a4f
2 changed files with 7 additions and 7 deletions

View File

@ -151,7 +151,7 @@ let format_name_cleaned (fmt : Format.formatter) (s : string) : unit =
let string_counter_map : int IntMap.t StringMap.t ref = ref StringMap.empty
let format_var (fmt : Format.formatter) (v : VarName.t) : unit =
let v_str = Mark.remove (VarName.get_info v) in
let v_str = clean_name (Mark.remove (VarName.get_info v)) in
let hash = VarName.hash v in
let local_id =
match StringMap.find_opt v_str !string_counter_map with
@ -170,8 +170,8 @@ let format_var (fmt : Format.formatter) (v : VarName.t) : unit =
in
if v_str = "_" then Format.fprintf fmt "_"
(* special case for the unit pattern *)
else if local_id = 0 then format_name_cleaned fmt v_str
else Format.fprintf fmt "%a_%d" format_name_cleaned v_str local_id
else if local_id = 0 then Format.pp_print_string fmt v_str
else Format.fprintf fmt "%s_%d" v_str local_id
let format_path ctx fmt p =
match List.rev p with

View File

@ -2,18 +2,18 @@ This test exposes a name clash between the scope function (`ScopeName,`
rewritten to `scope_name`) and the scope variable `scope_name`.
```catala
declaration scope SomeName:
declaration scope SomeNâme:
input i content integer
output o content integer
scope SomeName:
scope SomeNâme:
definition o equals i + 1
declaration scope B:
output some_name scope SomeName
output some_nâme scope SomeNâme
scope B:
definition some_name.i equals 1
definition some_nâme.i equals 1
```
```catala-test-inline