Add test to make sure that ${null} isn't a target

This commit is contained in:
Rudi Grinberg 2018-04-17 10:58:53 +07:00
parent 8c86604ee6
commit 9414913286
4 changed files with 12 additions and 4 deletions

View File

@ -1061,7 +1061,11 @@ module Infer = struct
module Unexp = Make(Unexpanded.Uast)(S_unexp)(Outcome_unexp)(struct
open Outcome_unexp
let ( +@ ) acc fn = { acc with targets = fn :: acc.targets }
let ( +@ ) acc fn =
if SW.is_var fn ~name:"null" then
acc
else
{ acc with targets = fn :: acc.targets }
let ( +< ) acc _ = acc
let ( +<! )= ( +< )
end)

View File

@ -198,3 +198,8 @@ let to_string t =
|> String.concat ~sep:""
let sexp_of_t t = Sexp.To_sexp.string (to_string t)
let is_var t ~name =
match t.items with
| [Var (_, v)] -> v = name
| _ -> false

View File

@ -43,6 +43,8 @@ val iter : t -> f:(Loc.t -> string -> unit) -> unit
(** [iter t ~f] iterates [f] over all variables of [t], the text
portions being ignored. *)
val is_var : t -> name:string -> bool
module type EXPANSION = sig
type t
(** The value to which variables are expanded. *)

View File

@ -1,4 +1 @@
$ jbuilder runtest --debug-dependency-path
File "jbuild", line 5, characters 26-33:
Warning: Aliases must not have targets, this target will be ignored.
This will become an error in the future.