Skip to content

Commit 1ec5302

Browse files
committed
Revert "Ensure syntax error locations appear in backtraces (#31881)"
This reverts the workaround in commit 5b637df, but keeps the tests. This will be handled in a more robust way by the intepreter backtrace machinery.
1 parent 1e50da2 commit 1ec5302

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

src/julia.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,6 @@ JL_DLLEXPORT jl_sym_t *jl_get_ARCH(void);
14481448
JL_DLLEXPORT jl_value_t *jl_environ(int i);
14491449

14501450
// throwing common exceptions
1451-
JL_DLLEXPORT jl_value_t *jl_vexceptionf(jl_datatype_t *exception_type,
1452-
const char *fmt, va_list args);
14531451
JL_DLLEXPORT void JL_NORETURN jl_error(const char *str);
14541452
JL_DLLEXPORT void JL_NORETURN jl_errorf(const char *fmt, ...);
14551453
JL_DLLEXPORT void JL_NORETURN jl_exceptionf(jl_datatype_t *ty,

src/rtutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ JL_DLLEXPORT void JL_NORETURN jl_error(const char *str)
4343

4444
extern int vasprintf(char **str, const char *fmt, va_list ap);
4545

46-
jl_value_t *jl_vexceptionf(jl_datatype_t *exception_type,
47-
const char *fmt, va_list args)
46+
static jl_value_t *jl_vexceptionf(jl_datatype_t *exception_type,
47+
const char *fmt, va_list args)
4848
{
4949
if (exception_type == NULL) {
5050
jl_printf(JL_STDERR, "ERROR: ");

src/toplevel.c

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "uv.h"
2121
#include "julia_assert.h"
2222
#include "intrinsics.h"
23-
#include "builtin_proto.h"
2423

2524
#ifdef __cplusplus
2625
extern "C" {
@@ -590,22 +589,6 @@ static jl_module_t *eval_import_from(jl_module_t *m JL_PROPAGATES_ROOT, jl_expr_
590589
return NULL;
591590
}
592591

593-
// Format msg and eval `throw(ErrorException(msg)))` in module `m`.
594-
// Used in `jl_toplevel_eval_flex` instead of `jl_errorf` so that the error
595-
// location in julia code gets into the backtrace.
596-
static void jl_eval_errorf(jl_module_t *m, const char* fmt, ...)
597-
{
598-
jl_value_t *throw_ex = (jl_value_t*)jl_exprn(call_sym, 2);
599-
JL_GC_PUSH1(&throw_ex);
600-
jl_exprargset(throw_ex, 0, jl_builtin_throw);
601-
va_list args;
602-
va_start(args, fmt);
603-
jl_exprargset(throw_ex, 1, jl_vexceptionf(jl_errorexception_type, fmt, args));
604-
va_end(args);
605-
jl_toplevel_eval_flex(m, throw_ex, 0, 0);
606-
JL_GC_POP();
607-
}
608-
609592
jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int fast, int expanded)
610593
{
611594
jl_ptls_t ptls = jl_get_ptls_states();
@@ -623,7 +606,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
623606
char *n = jl_symbol_name((jl_sym_t*)e), *n0 = n;
624607
while (*n == '_') ++n;
625608
if (*n == 0 && n > n0)
626-
jl_eval_errorf(m, "all-underscore identifier used as rvalue");
609+
jl_error("all-underscore identifier used as rvalue");
627610
}
628611
return jl_interpret_toplevel_expr_in(m, e, NULL, NULL);
629612
}
@@ -632,7 +615,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
632615

633616
if (ex->head == dot_sym) {
634617
if (jl_expr_nargs(ex) != 2)
635-
jl_eval_errorf(m, "syntax: malformed \".\" expression");
618+
jl_error("syntax: malformed \".\" expression");
636619
jl_value_t *lhs = jl_exprarg(ex, 0);
637620
jl_value_t *rhs = jl_exprarg(ex, 1);
638621
// only handle `a.b` syntax here, so qualified names can be eval'd in pure contexts
@@ -642,7 +625,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
642625
}
643626

644627
if (ptls->in_pure_callback) {
645-
jl_eval_errorf(m, "eval cannot be used in a generated function");
628+
jl_error("eval cannot be used in a generated function");
646629
}
647630

648631
jl_method_instance_t *mfunc = NULL;
@@ -684,8 +667,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
684667
}
685668
else {
686669
if (!jl_is_module(u))
687-
jl_eval_errorf(m, "invalid using path: \"%s\" does not name a module",
688-
jl_symbol_name(name));
670+
jl_errorf("invalid using path: \"%s\" does not name a module", jl_symbol_name(name));
689671
// `using A.B` syntax
690672
jl_module_using(m, u);
691673
if (m == jl_main_module && name == NULL) {
@@ -696,7 +678,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
696678
}
697679
}
698680
else {
699-
jl_eval_errorf(m, "syntax: malformed \"using\" statement");
681+
jl_error("syntax: malformed \"using\" statement");
700682
}
701683
}
702684
JL_GC_POP();
@@ -723,7 +705,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
723705
}
724706
}
725707
else {
726-
jl_eval_errorf(m, "syntax: malformed \"import\" statement");
708+
jl_error("syntax: malformed \"import\" statement");
727709
}
728710
}
729711
JL_GC_POP();
@@ -733,7 +715,7 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
733715
for (size_t i = 0; i < jl_array_len(ex->args); i++) {
734716
jl_sym_t *name = (jl_sym_t*)jl_array_ptr_ref(ex->args, i);
735717
if (!jl_is_symbol(name))
736-
jl_eval_errorf(m, "syntax: malformed \"export\" statement");
718+
jl_error("syntax: malformed \"export\" statement");
737719
jl_module_export(m, name);
738720
}
739721
JL_GC_POP();
@@ -773,9 +755,9 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
773755
}
774756
else if (head == error_sym || head == jl_incomplete_sym) {
775757
if (jl_expr_nargs(ex) == 0)
776-
jl_eval_errorf(m, "malformed \"%s\" expression", jl_symbol_name(head));
758+
jl_errorf("malformed \"%s\" expression", jl_symbol_name(head));
777759
if (jl_is_string(jl_exprarg(ex, 0)))
778-
jl_eval_errorf(m, "syntax: %s", jl_string_data(jl_exprarg(ex, 0)));
760+
jl_errorf("syntax: %s", jl_string_data(jl_exprarg(ex, 0)));
779761
jl_throw(jl_exprarg(ex, 0));
780762
}
781763
else if (jl_is_symbol(ex)) {

0 commit comments

Comments
 (0)