abap
abap copied to clipboard
wrong error: Variable name "i" already defined (check_syntax) [E]
The following code leads to the error:
Variable name "i" already defined (check_syntax) [E]
CLASS zcl_demo DEFINITION.
PUBLIC SECTION.
METHODS test
IMPORTING
word1 TYPE string
word2 TYPE string
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_demo IMPLEMENTATION.
METHOD text.
DATA(word1_table) = VALUE string_table( FOR i = 0 WHILE i < strlen( word1 )
( substring( val = word1 off = i len = 1 ) ) ).
DATA(word2_table) = VALUE string_table( FOR i = 0 WHILE i < strlen( word2 )
( substring( val = word2 off = i len = 1 ) ) ).
ENDMETHOD.
ENDCLASS.
The second VALUE command uses the same local variable "i" what is accepted by the ABAP compiler. But it leads to the error in exercism.
thanks, also see https://github.com/exercism/abap/issues/202