Skip to content

Commit d08c3fd

Browse files
panagosg7facebook-github-bot
authored andcommitted
[flow][type_sig] fix singleton type from_annot field
Summary: `as const` singleton types are considered originating from annotations, whereas those corresponding to const-declarations are not. This did not matter before, since we did not attempt to do any generalization, but it will soon, so I'm fixing here. Changelog: [internal] Reviewed By: gkz Differential Revision: D70763515 fbshipit-source-id: 0a5e133950a3b19b3cdd38bad46b07608e111035
1 parent 0c99955 commit d08c3fd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/typing/type_sig_merge.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ and merge_value ?(as_const = false) ?(const_decl = false) env file = function
11381138
| StringLit (loc, lit) ->
11391139
if as_const || const_decl then
11401140
let reason = Reason.(mk_annot_reason (RStringLit (OrdinaryName lit)) loc) in
1141-
Type.(DefT (reason, SingletonStrT { from_annot = false; value = Reason.OrdinaryName lit }))
1141+
Type.(DefT (reason, SingletonStrT { from_annot = as_const; value = Reason.OrdinaryName lit }))
11421142
else
11431143
let reason = Reason.(mk_reason RString loc) in
11441144
Type.(DefT (reason, StrGeneralT AnyLiteral))
@@ -1152,7 +1152,7 @@ and merge_value ?(as_const = false) ?(const_decl = false) env file = function
11521152
| NumberLit (loc, num, raw) ->
11531153
if as_const || const_decl then
11541154
let reason = Reason.(mk_annot_reason (RNumberLit raw) loc) in
1155-
Type.(DefT (reason, SingletonNumT { from_annot = false; value = (num, raw) }))
1155+
Type.(DefT (reason, SingletonNumT { from_annot = as_const; value = (num, raw) }))
11561156
else
11571157
let reason = Reason.(mk_reason RNumber loc) in
11581158
Type.(DefT (reason, NumGeneralT AnyLiteral))
@@ -1162,7 +1162,7 @@ and merge_value ?(as_const = false) ?(const_decl = false) env file = function
11621162
| BigIntLit (loc, bigint, raw) ->
11631163
if as_const || const_decl then
11641164
let reason = Reason.(mk_annot_reason (RBigIntLit raw) loc) in
1165-
Type.(DefT (reason, SingletonBigIntT { from_annot = false; value = (bigint, raw) }))
1165+
Type.(DefT (reason, SingletonBigIntT { from_annot = as_const; value = (bigint, raw) }))
11661166
else
11671167
let reason = Reason.(mk_reason RBigInt loc) in
11681168
Type.(DefT (reason, BigIntGeneralT AnyLiteral))
@@ -1172,7 +1172,7 @@ and merge_value ?(as_const = false) ?(const_decl = false) env file = function
11721172
| BooleanLit (loc, lit) ->
11731173
if as_const || const_decl then
11741174
let reason = Reason.(mk_annot_reason (RBooleanLit lit) loc) in
1175-
Type.(DefT (reason, SingletonBoolT { from_annot = false; value = lit }))
1175+
Type.(DefT (reason, SingletonBoolT { from_annot = as_const; value = lit }))
11761176
else
11771177
let reason = Reason.(mk_reason RBoolean loc) in
11781178
Type.(DefT (reason, BoolGeneralT))

0 commit comments

Comments
 (0)