Menu

#128 Function definitions need a whitespace before ":="

v1.1.x
fixed
None
v1.1.0
Bug Fix
2017-02-15
2017-01-24
Erik Hänel
No

For a function definition a whitespace is needed between the argument parenthesis and the definition operator. Otherwise the function definition throws a cryptic error about that function argument shall not contain the character "()".

Analysis:
The issue results effectively from a change in the behavior of getargatpos(). This function gathers arguments given at a defined position and needs whitespaces as separator characters. This is the intendend behavior, which means that the define function needs to check, if getargatpos() probably returned more than the desired parenthesis.

Implementation:
The following code lines were inserted after sFunctions[nDefine][3] = getArgAtPos(sExpr, sExpr.find('('));:

if (sFunctions[nDefine][3].front() == '('
    && getMatchingParenthesis(sFunctions[nDefine][3]) != string::npos
    && getMatchingParenthesis(sFunctions[nDefine][3]) != sFunctions[nDefine][3].length()-1)
    sFunctions[nDefine][3].erase(getMatchingParenthesis(sFunctions[nDefine][3])+1);

This solves the identified issue.

Documentation:
Not needed - Bug fix.

Tests:
Tested was every possible combination of whitespace around the definition operator. Tests were passed without any deviations. Bug fix accepted.

Discussion

  • Erik Hänel

    Erik Hänel - 2017-01-24
    • status: open --> accepted
     
  • Erik Hänel

    Erik Hänel - 2017-01-24
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,9 @@
     For a function definition a whitespace is needed between the argument parenthesis and the definition operator. Otherwise the function definition throws a cryptic error about that function argument shall not contain the character "()".
    +
    +**Analysis:**
    +
    +**Implementation:**
    +
    +**Documentation:**
    +
    +**Tests:**
    
    • status: accepted --> analyzing
     
  • Erik Hänel

    Erik Hänel - 2017-01-24
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,7 @@
     For a function definition a whitespace is needed between the argument parenthesis and the definition operator. Otherwise the function definition throws a cryptic error about that function argument shall not contain the character "()".
    
     **Analysis:**
    +The issue results effectively from a change in the behavior of `getargatpos()`. This function gathers arguments given at a defined position and needs whitespaces as separator characters. This is the intendend behavior, which means that the define function needs to check, if `getargatpos()` probably returned more than the desired parenthesis.
    
     **Implementation:**
    
    • status: analyzing --> implementing
     
  • Erik Hänel

    Erik Hänel - 2017-01-24
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,7 +4,16 @@
     The issue results effectively from a change in the behavior of `getargatpos()`. This function gathers arguments given at a defined position and needs whitespaces as separator characters. This is the intendend behavior, which means that the define function needs to check, if `getargatpos()` probably returned more than the desired parenthesis.
    
     **Implementation:**
    +The following code lines were inserted after `sFunctions[nDefine][3] = getArgAtPos(sExpr, sExpr.find('('));`:
    +~~~C
    +if (sFunctions[nDefine][3].front() == '('
    
    +    && getMatchingParenthesis(sFunctions[nDefine][3]) != string::npos
    +    && getMatchingParenthesis(sFunctions[nDefine][3]) != sFunctions[nDefine][3].length()-1)
    +    sFunctions[nDefine][3].erase(getMatchingParenthesis(sFunctions[nDefine][3])+1);
    +~~~
    +This solves the identified issue.
    
     **Documentation:**
    +Not needed - Bug fix.
    
     **Tests:**
    
    • status: implementing --> testing
     
  • Erik Hänel

    Erik Hänel - 2017-02-15
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -17,3 +17,4 @@
     Not needed - Bug fix.
    
     **Tests:**
    +Tested was every possible combination of whitespace around the definition operator. Tests were passed without any deviations. Bug fix accepted.
    
    • status: testing --> fixed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB