Skip to content

Commit cb10e40

Browse files
authored
Clean up lowering API (#58147)
This is preparatory work for experimental integration with JuliaLowering, which happened to be separable into its own PR. We currently have three lowering entry points doing slightly different things: `jl-expand-to-thunk`, `jl-expand-to-thunk-warn` (for complaining about ambiguous soft scope assignments during non-interactive use), and `jl-expand-to-thunk-stmt` (which wraps the expression in a block returning nothing before lowering it) and a bunch of C wrappers on top of those (see red nodes in the call graphs below). In this PR: - Make all lowering calls go through `jl_lower`, which just calls out to lisp for now, but will probably function like `jl_parse` does in a future PR. - Handle `warn` with an extra parameter - Delete most of the lowering wrappers, which were mainly a result of the three entry points - While we're breaking things in ast.c, take the opportunity to rename "expand"-prefixed functions to "lower"-prefixed ones (excluding macro expansion functions, which are called as the first part of lowering). Here's a call graph before this change, made by looking for callers of each lowering entry point and tracing back one or more steps (expect mistakes...). Macro expansion functions are mostly omitted for clarity. Blue is scheme, red is ast.c, and green is toplevel.c. ![graph](https://github.com/user-attachments/assets/b84a8662-06b4-45f6-937f-2d5ab5325ff0) After this change: ![graph(3)](https://github.com/user-attachments/assets/dd3765e2-1cd4-4ab8-bf85-6fa6eb7f9a74) #### todo? - ~~I'd like to see if we can eliminate the `stmt` boolean option from `jl_lower` and handle that another way; I'm just not sure it's worth the effort at the moment. We only use it in one place in `jl_eval_module_expr`. The original code path was added in #26304.~~
2 parents 16eca6e + 8d82bec commit cb10e40

File tree

11 files changed

+80
-133
lines changed

11 files changed

+80
-133
lines changed

base/expr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ end
16691669

16701670
# Implementation of generated functions
16711671
function generated_body_to_codeinfo(ex::Expr, defmod::Module, isva::Bool)
1672-
ci = ccall(:jl_expand, Any, (Any, Any), ex, defmod)
1672+
ci = ccall(:jl_lower_expr_mod, Any, (Any, Any), ex, defmod)
16731673
if !isa(ci, CodeInfo)
16741674
if isa(ci, Expr) && ci.head === :error
16751675
msg = ci.args[1]

base/meta.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Takes the expression `x` and returns an equivalent expression in lowered form
160160
for executing in module `m`.
161161
See also [`code_lowered`](@ref).
162162
"""
163-
lower(m::Module, @nospecialize(x)) = ccall(:jl_expand, Any, (Any, Any), x, m)
163+
lower(m::Module, @nospecialize(x)) = ccall(:jl_lower_expr_mod, Any, (Any, Any), x, m)
164164

165165
"""
166166
@lower [m] x

doc/src/devdocs/eval.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ the expression. Macro expansion involves a handoff from [`eval()`](@ref) (in Jul
8989
function `jl_macroexpand()` (written in `flisp`) to the Julia macro itself (written in - what
9090
else - Julia) via `fl_invoke_julia_macro()`, and back.
9191

92-
Typically, macro expansion is invoked as a first step during a call to [`Meta.lower()`](@ref)/`jl_expand()`,
92+
Typically, macro expansion is invoked as a first step during a call to [`Meta.lower()`](@ref)/`jl_lower_expr_mod()`,
9393
although it can also be invoked directly by a call to [`macroexpand()`](@ref)/`jl_macroexpand()`.
9494

9595
## [Type Inference](@id dev-type-inference)

src/ast.c

Lines changed: 39 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,98 +1275,65 @@ JL_DLLEXPORT jl_value_t *jl_macroexpand1(jl_value_t *expr, jl_module_t *inmodule
12751275
return expr;
12761276
}
12771277

1278-
// Lower an expression tree into Julia's intermediate-representation.
1279-
JL_DLLEXPORT jl_value_t *jl_expand(jl_value_t *expr, jl_module_t *inmodule)
1280-
{
1281-
return jl_expand_with_loc(expr, inmodule, "none", 0);
1282-
}
1283-
1284-
// Lowering, with starting program location specified
1285-
JL_DLLEXPORT jl_value_t *jl_expand_with_loc(jl_value_t *expr, jl_module_t *inmodule,
1286-
const char *file, int line)
1287-
{
1288-
return jl_expand_in_world(expr, inmodule, file, line, ~(size_t)0);
1289-
}
1290-
1291-
// Lowering, with starting program location and worldage specified
1292-
JL_DLLEXPORT jl_value_t *jl_expand_in_world(jl_value_t *expr, jl_module_t *inmodule,
1293-
const char *file, int line, size_t world)
1294-
{
1295-
JL_TIMING(LOWERING, LOWERING);
1296-
jl_timing_show_location(file, line, inmodule, JL_TIMING_DEFAULT_BLOCK);
1297-
JL_GC_PUSH1(&expr);
1298-
expr = jl_copy_ast(expr);
1299-
expr = jl_expand_macros(expr, inmodule, NULL, 0, world, 1);
1300-
expr = jl_call_scm_on_ast_and_loc("jl-expand-to-thunk", expr, inmodule, file, line);
1301-
JL_GC_POP();
1302-
return expr;
1303-
}
1304-
1305-
// Same as the above, but printing warnings when applicable
1306-
JL_DLLEXPORT jl_value_t *jl_expand_with_loc_warn(jl_value_t *expr, jl_module_t *inmodule,
1307-
const char *file, int line)
1278+
// Main entry point to flisp lowering. Most arguments are optional; see `jl_lower_expr_mod`.
1279+
// warn: Print any lowering warnings returned; otherwise ignore
1280+
JL_DLLEXPORT jl_value_t *jl_fl_lower(jl_value_t *expr, jl_module_t *inmodule,
1281+
const char *file, int line, size_t world, bool_t warn)
13081282
{
13091283
JL_TIMING(LOWERING, LOWERING);
13101284
jl_timing_show_location(file, line, inmodule, JL_TIMING_DEFAULT_BLOCK);
13111285
jl_array_t *kwargs = NULL;
1312-
JL_GC_PUSH2(&expr, &kwargs);
1286+
JL_GC_PUSH3(&expr, &kwargs, &inmodule);
13131287
expr = jl_copy_ast(expr);
1314-
expr = jl_expand_macros(expr, inmodule, NULL, 0, ~(size_t)0, 1);
1288+
expr = jl_expand_macros(expr, inmodule, NULL, 0, world, 1);
13151289
jl_ast_context_t *ctx = jl_ast_ctx_enter(inmodule);
13161290
fl_context_t *fl_ctx = &ctx->fl;
13171291
value_t arg = julia_to_scm(fl_ctx, expr);
1318-
value_t e = fl_applyn(fl_ctx, 4, symbol_value(symbol(fl_ctx, "jl-expand-to-thunk-warn")), arg,
1319-
symbol(fl_ctx, file), fixnum(line), fl_ctx->F);
1320-
expr = scm_to_julia(fl_ctx, e, inmodule);
1292+
value_t e = fl_applyn(fl_ctx, 3, symbol_value(symbol(fl_ctx, "jl-lower-to-thunk")), arg,
1293+
symbol(fl_ctx, file), fixnum(line));
1294+
value_t lwr = car_(e);
1295+
value_t warnings = car_(cdr_(e));
1296+
expr = scm_to_julia(fl_ctx, lwr, inmodule);
13211297
jl_ast_ctx_leave(ctx);
13221298
jl_sym_t *warn_sym = jl_symbol("warn");
1323-
if (jl_is_expr(expr) && ((jl_expr_t*)expr)->head == warn_sym) {
1324-
size_t nargs = jl_expr_nargs(expr);
1325-
for (int i = 0; i < nargs - 1; i++) {
1326-
jl_value_t *warning = jl_exprarg(expr, i);
1327-
size_t nargs = 0;
1328-
if (jl_is_expr(warning) && ((jl_expr_t*)warning)->head == warn_sym)
1329-
nargs = jl_expr_nargs(warning);
1330-
int kwargs_len = (int)nargs - 6;
1331-
if (nargs < 6 || kwargs_len % 2 != 0) {
1332-
jl_error("julia-logmsg: bad argument list - expected "
1333-
":warn level (symbol) group (symbol) id file line msg . kwargs");
1334-
}
1335-
jl_value_t *level = jl_exprarg(warning, 0);
1336-
jl_value_t *group = jl_exprarg(warning, 1);
1337-
jl_value_t *id = jl_exprarg(warning, 2);
1338-
jl_value_t *file = jl_exprarg(warning, 3);
1339-
jl_value_t *line = jl_exprarg(warning, 4);
1340-
jl_value_t *msg = jl_exprarg(warning, 5);
1341-
kwargs = jl_alloc_vec_any(kwargs_len);
1342-
for (int i = 0; i < kwargs_len; ++i) {
1343-
jl_array_ptr_set(kwargs, i, jl_exprarg(warning, i + 6));
1344-
}
1345-
JL_TYPECHK(logmsg, long, level);
1346-
jl_log(jl_unbox_long(level), NULL, group, id, file, line, (jl_value_t*)kwargs, msg);
1299+
for (; warn && iscons(warnings); warnings = cdr_(warnings)) {
1300+
jl_value_t *warning = scm_to_julia(fl_ctx, car_(warnings), inmodule);
1301+
size_t nargs = 0;
1302+
if (jl_is_expr(warning) && ((jl_expr_t*)warning)->head == warn_sym)
1303+
nargs = jl_expr_nargs(warning);
1304+
int kwargs_len = (int)nargs - 6;
1305+
if (nargs < 6 || kwargs_len % 2 != 0) {
1306+
jl_error("julia-logmsg: bad argument list - expected "
1307+
":warn level (symbol) group (symbol) id file line msg . kwargs");
13471308
}
1348-
expr = jl_exprarg(expr, nargs - 1);
1309+
jl_value_t *level = jl_exprarg(warning, 0);
1310+
jl_value_t *group = jl_exprarg(warning, 1);
1311+
jl_value_t *id = jl_exprarg(warning, 2);
1312+
jl_value_t *file = jl_exprarg(warning, 3);
1313+
jl_value_t *line = jl_exprarg(warning, 4);
1314+
jl_value_t *msg = jl_exprarg(warning, 5);
1315+
kwargs = jl_alloc_vec_any(kwargs_len);
1316+
for (int i = 0; i < kwargs_len; ++i) {
1317+
jl_array_ptr_set(kwargs, i, jl_exprarg(warning, i + 6));
1318+
}
1319+
JL_TYPECHK(logmsg, long, level);
1320+
jl_log(jl_unbox_long(level), NULL, group, id, file, line, (jl_value_t*)kwargs, msg);
13491321
}
13501322
JL_GC_POP();
13511323
return expr;
13521324
}
13531325

1354-
// expand in a context where the expression value is unused
1355-
JL_DLLEXPORT jl_value_t *jl_expand_stmt_with_loc(jl_value_t *expr, jl_module_t *inmodule,
1356-
const char *file, int line)
1326+
// Lower an expression tree into Julia's intermediate-representation.
1327+
JL_DLLEXPORT jl_value_t *jl_lower(jl_value_t *expr, jl_module_t *inmodule,
1328+
const char *file, int line, size_t world, bool_t warn)
13571329
{
1358-
JL_TIMING(LOWERING, LOWERING);
1359-
JL_GC_PUSH1(&expr);
1360-
expr = jl_copy_ast(expr);
1361-
expr = jl_expand_macros(expr, inmodule, NULL, 0, ~(size_t)0, 1);
1362-
expr = jl_call_scm_on_ast_and_loc("jl-expand-to-thunk-stmt", expr, inmodule, file, line);
1363-
JL_GC_POP();
1364-
return expr;
1330+
// TODO: Allow change of lowerer
1331+
return jl_fl_lower(expr, inmodule, file, line, world, warn);
13651332
}
13661333

1367-
JL_DLLEXPORT jl_value_t *jl_expand_stmt(jl_value_t *expr, jl_module_t *inmodule)
1334+
JL_DLLEXPORT jl_value_t *jl_lower_expr_mod(jl_value_t *expr, jl_module_t *inmodule)
13681335
{
1369-
return jl_expand_stmt_with_loc(expr, inmodule, "none", 0);
1336+
return jl_lower(expr, inmodule, "none", 0, ~(size_t)0, 0);
13701337
}
13711338

13721339
jl_code_info_t *jl_outer_ctor_body(jl_value_t *thistype, size_t nfields, size_t nsparams, jl_module_t *inmodule, const char *file, int line)

src/jl_exported_funcs.inc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@
125125
XX(jl_exit) \
126126
XX(jl_exit_on_sigint) \
127127
XX(jl_exit_threaded_region) \
128-
XX(jl_expand) \
129-
XX(jl_expand_stmt) \
130-
XX(jl_expand_stmt_with_loc) \
131-
XX(jl_expand_with_loc) \
132-
XX(jl_expand_with_loc_warn) \
133128
XX(jl_field_index) \
134129
XX(jl_field_isdefined) \
135130
XX(jl_gc_add_finalizer) \
@@ -289,6 +284,8 @@
289284
XX(jl_load_dynamic_library) \
290285
XX(jl_load_file_string) \
291286
XX(jl_lookup_code_address) \
287+
XX(jl_lower) \
288+
XX(jl_lower_expr_mod) \
292289
XX(jl_lseek) \
293290
XX(jl_lstat) \
294291
XX(jl_macroexpand) \

src/jlfrontend.scm

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
;; return a lambda expression representing a thunk for a top-level expression
110110
;; note: expansion of stuff inside module is delayed, so the contents obey
111111
;; toplevel expansion order (don't expand until stuff before is evaluated).
112-
(define (expand-toplevel-expr-- e file line)
112+
(define (lower-toplevel-expr-- e file line)
113113
(let ((lno (first-lineno e))
114114
(ex0 (julia-expand-macroscope e)))
115115
(if (and lno (or (not (length= lno 3)) (not (atom? (caddr lno))))) (set! lno #f))
@@ -118,8 +118,8 @@
118118
ex0
119119
(if lno `(toplevel ,lno ,ex0) ex0))
120120
(let* ((linenode (if (and lno (or (= line 0) (eq? file 'none))) lno `(line ,line ,file)))
121-
(ex (julia-expand0 ex0 linenode))
122-
(th (julia-expand1
121+
(ex (julia-lower0 ex0 linenode))
122+
(th (julia-lower1
123123
`(lambda () ()
124124
(scope-block
125125
,(blockify ex lno)))
@@ -142,38 +142,36 @@
142142
error incomplete))
143143
(and (memq (car e) '(global const)) (every symbol? (cdr e))))))
144144

145-
(define *in-expand* #f)
145+
(define *in-lowering* #f)
146146

147-
(define (expand-toplevel-expr e file line)
147+
(define (lower-toplevel-expr e file line)
148148
(cond ((or (atom? e) (toplevel-only-expr? e))
149149
(if (underscore-symbol? e)
150150
(error "all-underscore identifiers are write-only and their values cannot be used in expressions"))
151151
e)
152152
(else
153-
(let ((last *in-expand*))
153+
(let ((last *in-lowering*))
154154
(if (not last)
155155
(begin (reset-gensyms)
156-
(set! *in-expand* #t)))
157-
(begin0 (expand-toplevel-expr-- e file line)
158-
(set! *in-expand* last))))))
156+
(set! *in-lowering* #t)))
157+
(begin0 (lower-toplevel-expr-- e file line)
158+
(set! *in-lowering* last))))))
159159

160160
;; used to collect warnings during lowering, which are usually discarded
161161
;; unless logging is requested
162162
(define lowering-warning (lambda lst (void)))
163163

164164
;; expand a piece of raw surface syntax to an executable thunk
165165

166-
(define (expand-to-thunk- expr file line)
166+
(define (lower-to-thunk- expr file line)
167167
(error-wrap (lambda ()
168-
(expand-toplevel-expr expr file line))))
168+
(lower-toplevel-expr expr file line))))
169169

170-
(define (expand-to-thunk-stmt- expr file line)
171-
(expand-to-thunk- (if (toplevel-only-expr? expr)
172-
expr
173-
`(block ,expr (null)))
174-
file line))
175-
176-
(define (jl-expand-to-thunk-warn expr file line stmt)
170+
;; Returns a list `(,lowered-code ,warnings) where
171+
;; - warnings (currently only ambiguous soft scope assignments) may be ignored,
172+
;; e.g. when running interactively
173+
;; - more items may be added to the list later
174+
(define (jl-lower-to-thunk expr file line)
177175
(let ((warnings '()))
178176
(with-bindings
179177
;; Abuse scm_to_julia here to convert arguments to warn. This is meant for
@@ -183,30 +181,22 @@
183181
(let ((line (if (= warn_line 0) line warn_line))
184182
(file (if (eq? warn_file 'none) file warn_file)))
185183
(set! warnings (cons (list* 'warn level group (symbol (string file line)) file line lst) warnings))))))
186-
(let ((thunk (if stmt
187-
(expand-to-thunk-stmt- expr file line)
188-
(expand-to-thunk- expr file line))))
189-
(if (pair? warnings) `(warn ,@(reverse warnings) ,thunk) thunk)))))
190-
191-
(define (jl-expand-to-thunk expr file line)
192-
(expand-to-thunk- expr file line))
193-
194-
(define (jl-expand-to-thunk-stmt expr file line)
195-
(expand-to-thunk-stmt- expr file line))
184+
`(,(lower-to-thunk- expr file line)
185+
,(reverse warnings)))))
196186

197187
(define (jl-expand-macroscope expr)
198188
(error-wrap (lambda ()
199189
(julia-expand-macroscope expr))))
200190

201191
(define (jl-default-inner-ctor-body field-kinds file line)
202-
(expand-to-thunk- (default-inner-ctor-body (cdr field-kinds) file line) file line))
192+
(lower-to-thunk- (default-inner-ctor-body (cdr field-kinds) file line) file line))
203193

204194
(define (jl-default-outer-ctor-body args file line)
205-
(expand-to-thunk- (default-outer-ctor-body (cadr args) (caddr args) (cadddr args) file line) file line))
195+
(lower-to-thunk- (default-outer-ctor-body (cadr args) (caddr args) (cadddr args) file line) file line))
206196

207197
; run whole frontend on a string. useful for testing.
208198
(define (fe str)
209-
(expand-toplevel-expr (julia-parse str) 'none 0))
199+
(lower-toplevel-expr (julia-parse str) 'none 0))
210200

211201
(define (profile-e s)
212202
(with-exception-catcher

src/julia-syntax.scm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5331,7 +5331,7 @@ f(x) = yt(x)
53315331

53325332
;; expander entry point
53335333

5334-
(define (julia-expand1 ex file line)
5334+
(define (julia-lower1 ex file line)
53355335
(compact-and-renumber
53365336
(linearize
53375337
(closure-convert
@@ -5340,7 +5340,7 @@ f(x) = yt(x)
53405340

53415341
(define *current-desugar-loc* #f)
53425342

5343-
(define (julia-expand0 ex lno)
5343+
(define (julia-lower0 ex lno)
53445344
(with-bindings ((*current-desugar-loc* lno))
53455345
(trycatch (expand-forms ex)
53465346
(lambda (e)
@@ -5353,7 +5353,7 @@ f(x) = yt(x)
53535353
(error (string (cadr e) (format-loc *current-desugar-loc*))))
53545354
(raise e)))))
53555355

5356-
(define (julia-expand ex (file 'none) (line 0))
5357-
(julia-expand1
5358-
(julia-expand0
5356+
(define (julia-lower ex (file 'none) (line 0))
5357+
(julia-lower1
5358+
(julia-lower0
53595359
(julia-expand-macroscope ex) `(line ,line ,file)) file line))

src/julia.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,16 +2257,10 @@ JL_DLLEXPORT jl_value_t *jl_parse_all(const char *text, size_t text_len,
22572257
JL_DLLEXPORT jl_value_t *jl_parse_string(const char *text, size_t text_len,
22582258
int offset, int greedy);
22592259
// lowering
2260-
JL_DLLEXPORT jl_value_t *jl_expand(jl_value_t *expr, jl_module_t *inmodule);
2261-
JL_DLLEXPORT jl_value_t *jl_expand_with_loc(jl_value_t *expr, jl_module_t *inmodule,
2262-
const char *file, int line);
2263-
JL_DLLEXPORT jl_value_t *jl_expand_with_loc_warn(jl_value_t *expr, jl_module_t *inmodule,
2264-
const char *file, int line);
2265-
JL_DLLEXPORT jl_value_t *jl_expand_in_world(jl_value_t *expr, jl_module_t *inmodule,
2266-
const char *file, int line, size_t world);
2267-
JL_DLLEXPORT jl_value_t *jl_expand_stmt(jl_value_t *expr, jl_module_t *inmodule);
2268-
JL_DLLEXPORT jl_value_t *jl_expand_stmt_with_loc(jl_value_t *expr, jl_module_t *inmodule,
2269-
const char *file, int line);
2260+
JL_DLLEXPORT jl_value_t *jl_lower(jl_value_t *expr, jl_module_t *inmodule,
2261+
const char *file, int line, size_t world,
2262+
bool_t warn);
2263+
JL_DLLEXPORT jl_value_t *jl_lower_expr_mod(jl_value_t *expr, jl_module_t *inmodule);
22702264
// deprecated; use jl_parse_all
22712265
JL_DLLEXPORT jl_value_t *jl_parse_input_line(const char *text, size_t text_len,
22722266
const char *filename, size_t filename_len);

src/toplevel.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex
196196
for (int i = 0; i < jl_array_nrows(exprs); i++) {
197197
// process toplevel form
198198
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
199-
form = jl_expand_stmt_with_loc(jl_array_ptr_ref(exprs, i), newm, filename, lineno);
199+
form = jl_lower(jl_array_ptr_ref(exprs, i), newm, filename, lineno, ~(size_t)0, 0);
200200
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
201201
(void)jl_toplevel_eval_flex(newm, form, 1, 1, &filename, &lineno);
202202
}
@@ -808,7 +808,7 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_val
808808
size_t last_age = ct->world_age;
809809
if (!expanded && jl_needs_lowering(e)) {
810810
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
811-
ex = (jl_expr_t*)jl_expand_with_loc_warn(e, m, *toplevel_filename, *toplevel_lineno);
811+
ex = (jl_expr_t*)jl_lower(e, m, *toplevel_filename, *toplevel_lineno, ~(size_t)0, 1);
812812
ct->world_age = last_age;
813813
}
814814
jl_sym_t *head = jl_is_expr(ex) ? ex->head : NULL;
@@ -972,7 +972,7 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_val
972972
root = jl_array_ptr_ref(ex->args, i);
973973
if (jl_needs_lowering(root)) {
974974
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
975-
root = jl_expand_with_loc_warn(root, m, *toplevel_filename, *toplevel_lineno);
975+
root = jl_lower(root, m, *toplevel_filename, *toplevel_lineno, ~(size_t)0, 1);
976976
}
977977
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
978978
res = jl_toplevel_eval_flex(m, root, fast, 1, toplevel_filename, toplevel_lineno);
@@ -1151,8 +1151,7 @@ static jl_value_t *jl_parse_eval_all(jl_module_t *module, jl_value_t *text,
11511151
continue;
11521152
}
11531153
ct->world_age = jl_atomic_load_relaxed(&jl_world_counter);
1154-
expression = jl_expand_with_loc_warn(expression, module,
1155-
jl_string_data(filename), lineno);
1154+
expression = jl_lower(expression, module, jl_string_data(filename), lineno, ~(size_t)0, 1);
11561155
ct->world_age = jl_atomic_load_relaxed(&jl_world_counter);
11571156
result = jl_toplevel_eval_flex(module, expression, 1, 1, &filename_str, &lineno);
11581157
}

stdlib/REPL/src/REPL.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ const install_packages_hooks = Any[]
298298
# We need to do this for both the actual eval and macroexpand, since the latter can cause custom macro
299299
# code to run (and error).
300300
__repl_entry_lower_with_loc(mod::Module, @nospecialize(ast), toplevel_file::Ref{Ptr{UInt8}}, toplevel_line::Ref{Cint}) =
301-
ccall(:jl_expand_with_loc, Any, (Any, Any, Ptr{UInt8}, Cint), ast, mod, toplevel_file[], toplevel_line[])
301+
ccall(:jl_lower, Any, (Any, Any, Ptr{UInt8}, Cint, Csize_t, Cint), ast, mod, toplevel_file[], toplevel_line[], typemax(Csize_t), 0)
302302
__repl_entry_eval_expanded_with_loc(mod::Module, @nospecialize(ast), toplevel_file::Ref{Ptr{UInt8}}, toplevel_line::Ref{Cint}) =
303303
ccall(:jl_toplevel_eval_flex, Any, (Any, Any, Cint, Cint, Ptr{Ptr{UInt8}}, Ptr{Cint}), mod, ast, 1, 1, toplevel_file, toplevel_line)
304304

0 commit comments

Comments
 (0)