@@ -2677,13 +2677,31 @@ let save_signature_with_imports ~alerts sg modname filename imports =
2677
2677
save_signature_with_transform with_imports
2678
2678
~alerts sg modname filename
2679
2679
2680
- (* Make the initial environment *)
2680
+ (* Make the initial environment, without language extensions *)
2681
2681
let (initial_safe_string, initial_unsafe_string) =
2682
2682
Predef. build_initial_env
2683
2683
(add_type ~check: false )
2684
2684
(add_extension ~check: false ~rebind: false )
2685
2685
empty
2686
2686
2687
+ let add_language_extension_types env =
2688
+ lazy
2689
+ ((* CR ccasinghino for mslater: Here, check the simd extension. If it's on,
2690
+ return [add_simd_extension_types (add_type ~check:false) env].
2691
+ Otherwise, return env. *)
2692
+ env)
2693
+
2694
+ (* Some predefined types are part of language extensions, and we don't want to
2695
+ make them available in the initial environment if those extensions are not
2696
+ turned on. We can't do this at startup because command line flags haven't
2697
+ been parsed yet. So, we make the initial environment lazy.
2698
+
2699
+ If language extensions are adjusted after [initial_safe_string] and
2700
+ [initial_unsafe_string] are forced, these environments may be inaccurate.
2701
+ *)
2702
+ let initial_safe_string = add_language_extension_types initial_safe_string
2703
+ let initial_unsafe_string = add_language_extension_types initial_unsafe_string
2704
+
2687
2705
(* Tracking usage *)
2688
2706
2689
2707
let mark_module_used uid =
@@ -3174,7 +3192,7 @@ let lookup_all_dot_constructors ~errors ~use ~loc usage l s env =
3174
3192
| Longident. Lident "*predef*" ->
3175
3193
(* Hack to support compilation of default arguments *)
3176
3194
lookup_all_ident_constructors
3177
- ~errors ~use ~loc usage s initial_safe_string
3195
+ ~errors ~use ~loc usage s ( Lazy. force initial_safe_string)
3178
3196
| _ ->
3179
3197
let (_, comps) = lookup_structure_components ~errors ~use ~loc l env in
3180
3198
match NameMap. find s comps.comp_constrs with
0 commit comments