Skip to content

Commit

Permalink
fix(test): fix initialization order in Test_Parser
Browse files Browse the repository at this point in the history
Parser's constructor might use the diag reporter (because
Parser::Parser calls Lexer::Lexer which lexes the first token). Ensure
Test_Parser's diag reporter is initialized before making the Parser.
  • Loading branch information
strager committed Mar 3, 2024
1 parent d09997c commit 2990b04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/quick-lint-js/parse-support.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ class Test_Parser {
Source_Location caller);

private:
Monotonic_Allocator diag_allocator_{"Test_Parser::diag_allocator_"};
Diag_List_Diag_Reporter diag_reporter_{&this->diag_allocator_};

Padded_String code_;
Spy_Visitor errors_;
Failing_Diag_Reporter failing_reporter_;
quick_lint_js::Parser parser_;

Monotonic_Allocator diag_allocator_{"Test_Parser::diag_allocator_"};
Diag_List_Diag_Reporter diag_reporter_{&this->diag_allocator_};

public:
// Aliases for convenience.
std::vector<std::string_view>& visits = this->errors_.visits;
Expand Down

0 comments on commit 2990b04

Please sign in to comment.