Quellcode durchsuchen

[typer] support `@:allow(std)` to allow toplevel types

closes #3404
Simon Krajewski vor 7 Jahren
Ursprung
Commit
9201a3b8e4
1 geänderte Dateien mit 8 neuen und 2 gelöschten Zeilen
  1. 8 2
      src/context/typecore.ml

+ 8 - 2
src/context/typecore.ml

@@ -356,8 +356,14 @@ let rec can_access ctx ?(in_overload=false) c cf stat =
 		let rec loop = function
 			| (m2,el,_) :: l when m = m2 ->
 				List.exists (fun e ->
-					let p = expr_path [] e in
-					(p <> [] && chk_path p path)
+					match fst e with
+					| EConst (Ident "std") ->
+						(* If we have `@:allow(std)`, check if our path has exactly two elements
+						   (type name + field name) *)
+						(match path with [_;_] -> true | _ -> false)
+					| _ ->
+						let p = expr_path [] e in
+						(p <> [] && chk_path p path)
 				) el
 				|| loop l
 			| _ :: l -> loop l