Skip to content

Commit

Permalink
Fix some other coverage leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed Jul 10, 2023
1 parent 848528d commit 947b86a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .run/spicetest.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spicetest" type="CMakeGoogleTestRunConfigurationType" factoryName="Google Test" PROGRAM_PARAMS="--update-refs=false" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spicetest" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spicetest" TEST_MODE="SUITE_TEST">
<configuration default="false" name="spicetest" type="CMakeGoogleTestRunConfigurationType" factoryName="Google Test" PROGRAM_PARAMS="--update-refs=false" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spicetest" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spicetest" TEST_CLASS="TypeCheckerTests" TEST_MODE="SUITE_TEST">
<envs>
<env name="RUN_TESTS" value="ON" />
<env name="SPICE_STD_DIR" value="$PROJECT_DIR$/std" />
Expand Down
4 changes: 2 additions & 2 deletions src/symboltablebuilder/SymbolTableEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void SymbolTableEntry::updateType(const SymbolType &newType, bool overwriteExist
void SymbolTableEntry::updateState(const LifecycleState &newState, ASTNode *node, bool force) {
const LifecycleState oldState = lifecycle.getCurrentState();
// Check if this is a constant variable and is already initialized
if (newState != DEAD && oldState != DECLARED && type.isConst() && !force)
throw SemanticError(node, REASSIGN_CONST_VARIABLE, "Not re-assignable variable '" + name + "'");
if (newState != DEAD && oldState != DECLARED && type.isConst() && !force) // GCOV_EXCL_LINE
throw CompilerError(INTERNAL_ERROR, "Not re-assignable variable '" + name + "'"); // GCOV_EXCL_LINE
if (newState == DEAD && oldState == DECLARED) // GCOV_EXCL_LINE
throw CompilerError(INTERNAL_ERROR, "Cannot destruct uninitialized variable '" + name + "'"); // GCOV_EXCL_LINE
if (newState == DEAD && oldState == DEAD) // GCOV_EXCL_LINE
Expand Down
2 changes: 1 addition & 1 deletion src/visualizer/ASTVisualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ std::string ASTVisualizer::getSpaces() const {
for (int i = 0; i < currentTabs; i++)
spaces += " ";
return spaces;
}
} // GCOVR_EXCL_LINE (false positive)

} // namespace spice::compiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Error|Semantic] ./test-files/typechecker/variables/error-reassign-const-var/source.spice:3:5:
Cannot re-assign constant variable: Trying to assign value to a constant

3 i = 1234;
^
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
f<int> main() {
const int i = 123;
i = 1234;
}

0 comments on commit 947b86a

Please sign in to comment.