@@ -79,13 +79,16 @@ impl LanguageConfiguration {
7979 if let Some ( ( builtins_path, builtins_source) ) = builtins_source {
8080 let mut builtins_globals = Variables :: new ( ) ;
8181
82- builtins_globals
83- . add ( FILE_PATH_VAR . into ( ) , BUILTINS_FILENAME . into ( ) )
84- . expect ( "failed to add file path variable" ) ;
85-
8682 if let Some ( builtins_config) = builtins_config {
8783 Loader :: load_globals_from_config_str ( builtins_config, & mut builtins_globals) ?;
8884 }
85+
86+ if builtins_globals. get ( & FILE_PATH_VAR . into ( ) ) . is_some ( ) {
87+ builtins_globals
88+ . add ( FILE_PATH_VAR . into ( ) , BUILTINS_FILENAME . into ( ) )
89+ . expect ( "failed to add file path variable" ) ;
90+ }
91+
8992 let file = builtins. add_file ( BUILTINS_FILENAME ) . unwrap ( ) ;
9093 sgl. build_stack_graph_into (
9194 & mut builtins,
@@ -337,11 +340,14 @@ impl Loader {
337340 let file = graph. add_file ( & file_name) . unwrap ( ) ;
338341 let mut globals = Variables :: new ( ) ;
339342
340- globals
341- . add ( FILE_PATH_VAR . into ( ) , BUILTINS_FILENAME . into ( ) )
342- . expect ( "failed to add file path variable" ) ;
343-
344343 Self :: load_globals_from_config_str ( & config, & mut globals) ?;
344+
345+ if globals. get ( & FILE_PATH_VAR . into ( ) ) . is_some ( ) {
346+ globals
347+ . add ( FILE_PATH_VAR . into ( ) , BUILTINS_FILENAME . into ( ) )
348+ . expect ( "failed to add file path variable" ) ;
349+ }
350+
345351 sgl. build_stack_graph_into ( graph, file, & source, & globals, cancellation_flag)
346352 . map_err ( |err| LoadError :: Builtins {
347353 inner : err,
0 commit comments