Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let/const #784

Closed
wants to merge 14 commits into from
15 changes: 15 additions & 0 deletions src/typing/constraint_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,15 @@ module Scope = struct

and implicit_let_kinds =
| ClassNameBinding
| CatchParamBinding
| FunctionBinding

let string_of_value_kind = function
| Const -> "const"
| Let None -> "let"
| Let (Some ClassNameBinding) -> "class"
| Let (Some CatchParamBinding) -> "catch"
| Let (Some FunctionBinding) -> "function"
| Var -> "var"

type value_binding = {
Expand Down Expand Up @@ -765,6 +769,13 @@ module Scope = struct
else Value { v with specific = make_specific v.general }
| Type _ -> entry

let is_lex = function
| Type _ -> false
| Value v ->
match v.kind with
| Const -> true
| Let _ -> true
| _ -> false
end

(* keys for refinements *)
Expand Down Expand Up @@ -904,6 +915,10 @@ module Scope = struct
| Some f -> scope |> update_entries (Entry.havoc ~name f)
| None -> ()

let is_lex scope =
match scope.kind with
| LexScope -> true
| _ -> false
end

(***************************************)
Expand Down
8 changes: 7 additions & 1 deletion src/typing/constraint_js.mli
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ module Scope: sig
val string_of_state: state -> string

type value_kind = Const | Let of implicit_let_kinds option | Var
and implicit_let_kinds = ClassNameBinding
and implicit_let_kinds =
| ClassNameBinding
| CatchParamBinding
| FunctionBinding

val string_of_value_kind: value_kind -> string

Expand Down Expand Up @@ -327,6 +330,8 @@ module Scope: sig

val string_of_kind: t -> string
val havoc: ?name:string -> (Type.t -> Type.t) -> string -> t -> t

val is_lex: t -> bool
end

module Key: sig
Expand Down Expand Up @@ -379,6 +384,7 @@ module Scope: sig

val havoc: ?name: string -> ?make_specific: (Type.t -> Type.t) -> t -> unit

val is_lex: t -> bool
end

(***************************************)
Expand Down
Loading