A colleague noticed something interesting: If we use the same variable name in multiple FOR or LET expressions with different data types, we get type conflicts.

The documentation calls them "local auxiliary field", which I always interpreted as local to the expression - particularly since it also states "There is no way of accessing an auxiliary field statically outside its expression".

But:

TYPES numtab TYPE STANDARD TABLE OF i WITH DEFAULT KEY.
TYPES chartab TYPE STANDARD TABLE OF c WITH DEFAULT KEY.
DATA(nums) = VALUE numtab( ( 1 ) ( 2 ) ( 3 ) ).
DATA(nums2) = VALUE numtab( FOR x IN nums ( x ) ).
DATA(chars) = VALUE chartab( ( 'A' ) ( 'B' ) ( 'C' ) ).
DATA(chars2) = VALUE chartab( FOR x IN chars ( x ) ). "Error 1
"Just for kicks let's try the same with LET
DATA(nums3) = VALUE numtab( LET a = 1 IN ( a ) ).
DATA(chars3) = VALUE chartab( LET a = 'A' IN ( a ) ). "Error 2
x = 5. "Error 3: X cannot be used here

Errors 1 and 2 are "X was already declared with the type "I" and cannot be used with the type "C" here.

Error 3 states that "X cannot be used here" which matches the docu.

So is the documentation vaguely worded or is this not as local as it is designed to be?

## Add comment