Ver Fonte

use quoted names for anonymous structure fields

Simon Krajewski há 11 anos atrás
pai
commit
329f288e3b
3 ficheiros alterados com 5 adições e 4 exclusões
  1. 2 1
      genpy.ml
  2. 3 3
      std/python/Boot.hx
  3. 0 0
      tests/unit/issues/Issue2604.hx

+ 2 - 1
genpy.ml

@@ -1150,7 +1150,8 @@ module Printer = struct
 		String.concat sep (List.map (print_expr pctx) el)
 
 	and print_exprs_named pctx sep fl =
-		String.concat sep (List.map (fun (s,e) -> Printf.sprintf "%s = %s" (handle_keywords s) (print_expr pctx e)) fl)
+		let args = String.concat sep (List.map (fun (s,e) -> Printf.sprintf "'%s': %s" (handle_keywords s) (print_expr pctx e)) fl) in
+		Printf.sprintf "{%s}" args
 
 	let handle_keywords s =
 		KeywordHandler.handle_keywords s

+ 3 - 3
std/python/Boot.hx

@@ -12,10 +12,10 @@ import builtins as _hx_builtin
 _hx_classes = dict()
 
 class _hx_AnonObject(object):
-    def __init__(self, **kwargs):
-        self.__dict__.update(kwargs)
+    def __init__(self, fields):
+        self.__dict__ = fields
 
-_hx_c = _hx_AnonObject()
+_hx_c = _hx_AnonObject({})
 
 _hx_c._hx_AnonObject = _hx_AnonObject
 

+ 0 - 0
tests/unit/issues/Issue2604.hx.disabled → tests/unit/issues/Issue2604.hx