diff --git a/src/parser.cpp b/src/parser.cpp index f73ef4693..8bd8a694f 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -369,7 +369,7 @@ void parser_t::stack_trace_internal(size_t block_idx, wcstring *buff) const { switch (b->type()) { case SOURCE: { const source_block_t *sb = static_cast(b); - const wchar_t *source_dest = sb->source_file; + const wchar_t *source_dest = sb->sourced_file; append_format(*buff, _(L"from sourcing file %ls\n"), user_presentable_path(source_dest).c_str()); break; @@ -503,7 +503,7 @@ const wchar_t *parser_t::current_filename() const { return function_get_definition_file(fb->function_name); } else if (b->type() == SOURCE) { const source_block_t *sb = static_cast(b); - return sb->source_file; + return sb->sourced_file; } } @@ -844,7 +844,7 @@ function_block_t::function_block_t(wcstring name, wcstring_list_t args, bool sha this->function_args = std::move(args); } -source_block_t::source_block_t(const wchar_t *src) : block_t(SOURCE), source_file(src) {} +source_block_t::source_block_t(const wchar_t *src) : block_t(SOURCE) { this->sourced_file = src; } for_block_t::for_block_t() : block_t(FOR) {} diff --git a/src/parser.h b/src/parser.h index 76b627e3e..0911701d6 100644 --- a/src/parser.h +++ b/src/parser.h @@ -80,6 +80,10 @@ struct block_t { wcstring function_name{}; wcstring_list_t function_args{}; + // If this is a source block, the source'd file, interned. + // Otherwise nothing. + const wchar_t *sourced_file{}; + block_type_t type() const { return this->block_type; } /// Description of the block, for debugging. @@ -103,7 +107,6 @@ struct function_block_t : public block_t { }; struct source_block_t : public block_t { - const wchar_t *const source_file; explicit source_block_t(const wchar_t *src); };