Skip to content

Commit

Permalink
fix: Invalid CA variable definition may crash the language server
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Aug 26, 2022
1 parent 0bda7f1 commit 70516e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Improve performance of generating document outline
- Reduce memory footprint
- The language server may crash when a line is continued by the preprocessor output
- Invalid CA variable definition may crash the language server

## [1.3.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/1.2.0...1.3.0) (2022-06-30)

Expand Down
2 changes: 1 addition & 1 deletion parser_library/src/parsing/grammar/ca_expr_rules.g4
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ var_def returns [vs_ptr vs]
$vs = std::make_unique<created_variable_symbol>(std::move($var_def_name.created_name), std::move($var_def_substr.value), r);
};

var_def_name returns [id_index name, concat_chain created_name]
var_def_name returns [id_index name = id_storage::empty_id, concat_chain created_name]
: AMPERSAND?
(
vs_id {$name = $vs_id.name;}
Expand Down
14 changes: 14 additions & 0 deletions parser_library/test/expressions/ca_var_sym_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "gmock/gmock.h"

#include "../common_testing.h"
#include "expressions/conditional_assembly/terms/ca_constant.h"
#include "expressions/conditional_assembly/terms/ca_var_sym.h"
#include "expressions/evaluation_context.h"
Expand Down Expand Up @@ -65,3 +66,16 @@ TEST(ca_var_sym_created, undefined_attributes)

ASSERT_EQ(res.size(), 0U);
}

TEST(ca_var_sym, invalid_definitions)
{
std::string input = R"(
GBLC (([
GBLC (([
)";
analyzer a(input);
a.analyze();
a.collect_diags();

EXPECT_TRUE(matches_message_codes(a.diags(), { "S0002", "S0002" }));
}

0 comments on commit 70516e4

Please sign in to comment.