Skip to content

Commit 2fea3f5

Browse files
committed
[typing] Fix const literal reason description
1 parent 93d2dbe commit 2fea3f5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/typing/statement.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4294,29 +4294,29 @@ and literal ?(is_const=false) cx loc lit =
42944294
then Literal (None, s), RString
42954295
else AnyLiteral, RLongStringLit (max_literal_length)
42964296
in
4297-
let lit_type = match lit with
4298-
| Literal (_, s) when is_const -> SingletonStrT s
4299-
| _ -> StrT lit
4297+
let lit_type, r_desc = match (lit, r_desc) with
4298+
| (Literal (_, s), _) when is_const -> SingletonStrT s, RStringLit s
4299+
| (_, r_desc) -> StrT lit, r_desc
43004300
in
43014301
DefT (annot_reason (mk_reason r_desc loc), make_trust (), lit_type)
43024302
end
43034303

43044304
| Boolean b ->
4305-
let lit_type = if is_const
4306-
then SingletonBoolT b
4307-
else BoolT (Some b)
4305+
let lit_type, r_desc = if is_const
4306+
then SingletonBoolT b, RBooleanLit b
4307+
else BoolT (Some b), RBoolean
43084308
in
4309-
DefT (annot_reason (mk_reason RBoolean loc), make_trust (), lit_type)
4309+
DefT (annot_reason (mk_reason r_desc loc), make_trust (), lit_type)
43104310

43114311
| Null ->
43124312
NullT.at loc |> with_trust make_trust
43134313

43144314
| Number f ->
4315-
let lit_type = if is_const
4316-
then SingletonNumT (f, lit.raw)
4317-
else NumT (Literal (None, (f, lit.raw)))
4315+
let lit_type, r_desc = if is_const
4316+
then SingletonNumT (f, lit.raw), RNumberLit lit.raw
4317+
else NumT (Literal (None, (f, lit.raw))), RNumber
43184318
in
4319-
DefT (annot_reason (mk_reason RNumber loc), make_trust (), lit_type)
4319+
DefT (annot_reason (mk_reason r_desc loc), make_trust (), lit_type)
43204320

43214321
| BigInt _ ->
43224322
let reason = annot_reason (mk_reason (RBigIntLit lit.raw) loc) in

0 commit comments

Comments
 (0)