Menu

#296 Add error, if there's an unfinished block in a procedure

v1.1.x
closed
None
v1.1.0
Change Request
2018-04-26
2018-03-16
Erik Hänel
No

Add an exception, if the current block is not closed until the procedure is left like in this case

procedure $some_procedure()
    var some_var
    if (some_var)
        print #some_var
    return false;
endprocedure

Analysis:
This can be done simply by adding the following lines in "procedure.cpp":

if (getLoop())
{
    if (_option.getUseDebugger())
        _option._debug.gatherInformations(_varfactory.sLocalVars,
            _varfactory.nLocalVarMapSize, _varfactory.dLocalVars,
            _varfactory.sLocalStrings, _varfactory.nLocalStrMapSize,
            _data.getStringVars(), sProcCommandLine, sCurrentProcedureName,
            nCurrentLine);
    resetProcedure(_parser, bSupressAnswer_back);
    throw SyntaxError(SyntaxError::IF_OR_LOOP_SEEMS_NOT_TO_BE_CLOSED, 
        "endprocedure", SyntaxError::invalid_position, "$" + sProc + "()");
}

and this to the catches in "kernel.cpp": _procedure.reset().

Implementation:
The change was implemented as proposed by the analysis. Implementation tests were passed successfully.

Documentation:
Not needed - Internal change.

Tests:
The change was tested and no deviations were detected. Change implemented successfully.

Discussion

  • Erik Hänel

    Erik Hänel - 2018-03-16
    • status: open --> accepted
     
  • Erik Hänel

    Erik Hänel - 2018-03-16
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -6,3 +6,11 @@
                 print #some_var
             return false;
         endprocedure
    
    +  
    +**Analysis:**
    +
    +**Implementation:**
    +
    +**Documentation:**
    +
    +**Tests:**
    
    • status: accepted --> analyzing
     
  • Erik Hänel

    Erik Hänel - 2018-03-16
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -8,6 +8,23 @@
         endprocedure
    
     **Analysis:**
    +This can be done simply by adding the following lines in "procedure.cpp":
    +
    
    +    :::C++
    +    if (getLoop())
    +    {
    +        if (_option.getUseDebugger())
    +            _option._debug.gatherInformations(_varfactory.sLocalVars,
    +                _varfactory.nLocalVarMapSize, _varfactory.dLocalVars,
    +                _varfactory.sLocalStrings, _varfactory.nLocalStrMapSize,
    +                _data.getStringVars(), sProcCommandLine, sCurrentProcedureName,
    +                nCurrentLine);
    +        resetProcedure(_parser, bSupressAnswer_back);
    +        throw SyntaxError(SyntaxError::IF_OR_LOOP_SEEMS_NOT_TO_BE_CLOSED, 
    +            "endprocedure", SyntaxError::invalid_position, "$" + sProc + "()");
    +    }
    +    
    +and this to the `catch`es in "kernel.cpp": `_procedure.reset()`.
    
     **Implementation:**
    
     
  • Erik Hänel

    Erik Hänel - 2018-03-16
    • status: analyzing --> implementing
     
  • Erik Hänel

    Erik Hänel - 2018-03-16
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -27,7 +27,9 @@
     and this to the `catch`es in "kernel.cpp": `_procedure.reset()`.
    
     **Implementation:**
    +The change was implemented as proposed by the analysis. Implementation tests were passed successfully.
    
     **Documentation:**
    +Not needed - Internal change.
    
     **Tests:**
    
    • status: implementing --> testing
     
  • Erik Hänel

    Erik Hänel - 2018-04-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -33,3 +33,4 @@
     Not needed - Internal change.
    
     **Tests:**
    +The change was tested and no deviations were detected. Change implemented successfully.
    
    • status: testing --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB