Skip to content

Commit 2990b04

Browse files
committed
fix(test): fix initialization order in Test_Parser
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.
1 parent d09997c commit 2990b04

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/quick-lint-js/parse-support.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ class Test_Parser {
185185
Source_Location caller);
186186

187187
private:
188+
Monotonic_Allocator diag_allocator_{"Test_Parser::diag_allocator_"};
189+
Diag_List_Diag_Reporter diag_reporter_{&this->diag_allocator_};
190+
188191
Padded_String code_;
189192
Spy_Visitor errors_;
190193
Failing_Diag_Reporter failing_reporter_;
191194
quick_lint_js::Parser parser_;
192195

193-
Monotonic_Allocator diag_allocator_{"Test_Parser::diag_allocator_"};
194-
Diag_List_Diag_Reporter diag_reporter_{&this->diag_allocator_};
195-
196196
public:
197197
// Aliases for convenience.
198198
std::vector<std::string_view>& visits = this->errors_.visits;

0 commit comments

Comments
 (0)