From f005a8c7c3f3e9eeca3e0b253992d891ba5189ac Mon Sep 17 00:00:00 2001 From: Chris Foster Date: Mon, 4 May 2020 12:18:25 +1000 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Jameson Nash --- base/loading.jl | 2 +- base/stacktraces.jl | 7 +++---- src/ast.c | 10 ++++------ stdlib/Distributed/test/distributed_exec.jl | 1 - 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index 5af454ecce440..480c401ebe647 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1105,7 +1105,7 @@ function include_string(mapexpr::Function, mod::Module, code::AbstractString, catch exc # TODO: Now that stacktraces are more reliable we should remove # LoadError and expose the real error type directly. - rethrow(LoadError(String(loc.file), loc.line, exc)) + rethrow(LoadError(filename, loc.line, exc)) end end diff --git a/base/stacktraces.jl b/base/stacktraces.jl index ff5f9374715ed..9c13355ce789c 100644 --- a/base/stacktraces.jl +++ b/base/stacktraces.jl @@ -275,11 +275,10 @@ function Base.parentmodule(frame::StackFrame) return def else return (def::Method).module - return def.module end else - # Bug: currently the module is not available for inlined frames and - # frames arising from the interpreter. + # The module is not always available (common reasons include inlined + # frames and frames arising from the interpreter) nothing end end @@ -290,7 +289,7 @@ end Returns whether the `frame` is from the provided `Module` """ function from(frame::StackFrame, m::Module) - parentmodule(frame) == m + return parentmodule(frame) === m end end diff --git a/src/ast.c b/src/ast.c index 6761823f9d8b6..ff32bc751d443 100644 --- a/src/ast.c +++ b/src/ast.c @@ -1198,13 +1198,11 @@ JL_DLLEXPORT jl_value_t *jl_parse(const char *text, size_t text_len, jl_value_t jl_value_t *result = jl_apply(args, 5); ptls->world_age = last_age; args[0] = result; // root during error checks below - if (!jl_is_svec(result)) { - jl_type_error("jl_parse", (jl_value_t*)jl_simplevector_type, result); - } - else if (jl_svec_len(result) != 2 || !jl_is_expr(jl_svecref(result, 0)) || - !jl_is_long(jl_svecref(result, 1))) { + JL_TYPECHK(parse, simplevector, result); + if (jl_svec_len(result) != 2) jl_error("Result from parser should be `svec(a::Expr, b::Int)`"); - } + JL_TYPECHK(parse, expr, jl_svecref(result, 0)); + JL_TYPECHK(parse, long, jl_svecref(result, 1)); JL_GC_POP(); return result; } diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 3887b5b68f75a..379a2b5b46fb5 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -1486,7 +1486,6 @@ let function test_include_fails_to_open_file(fname) try include(fname) - false catch exc path = joinpath(@__DIR__, fname) @test exc isa SystemError