|
@@ -809,14 +809,16 @@ let generate_package_create ctx (p,_) =
|
|
|
| [] -> print ctx "var "
|
|
|
| _ -> loop [] p
|
|
|
|
|
|
-let check_field_name c f =
|
|
|
+let check_field_name c f stat =
|
|
|
match f.cf_name with
|
|
|
| "prototype" | "__proto__" | "constructor" ->
|
|
|
error ("The field name '" ^ f.cf_name ^ "' is not allowed in JS") (match f.cf_expr with None -> c.cl_pos | Some e -> e.epos);
|
|
|
+ | "length" when stat ->
|
|
|
+ error ("The field name '" ^ f.cf_name ^ "' is not allowed for statics in JS") (match f.cf_expr with None -> c.cl_pos | Some e -> e.epos);
|
|
|
| _ -> ()
|
|
|
|
|
|
let gen_class_static_field ctx c f =
|
|
|
- check_field_name c f;
|
|
|
+ check_field_name c f true;
|
|
|
match f.cf_expr with
|
|
|
| None ->
|
|
|
print ctx "%s%s = null" (s_path ctx c.cl_path) (field f.cf_name);
|
|
@@ -835,7 +837,7 @@ let gen_class_static_field ctx c f =
|
|
|
ctx.statics <- (c,f.cf_name,e) :: ctx.statics
|
|
|
|
|
|
let gen_class_field ctx c f =
|
|
|
- check_field_name c f;
|
|
|
+ check_field_name c f false;
|
|
|
newprop ctx;
|
|
|
print ctx "%s: " (anon_field f.cf_name);
|
|
|
match f.cf_expr with
|