SOMns icon indicating copy to clipboard operation
SOMns copied to clipboard

Immutable local variables seemingly not working

Open smarr opened this issue 8 years ago • 0 comments

The following code seems to be able to write to maxDiff, which should cause a DoesNotUnderstand instead, because there is not 'setter' available for maxDiff.

private verifyResult: size = (
      | maxDiff = 0.0. |

      LU doIndexes: [:i |
        (LU at: i) doIndexes: [:j |
          | v = 0.0.
            k ::= 1.
            diff |

          [ k < i and: [ k <= j ] ] whileTrue: [
            (* i print. ' ' print. k print. ' ' print. j print. ' ' print. *)
            v:: v + ((LU at: i) at: k) * ((LU at: k) at: j).
            (* v println. *)
            k:: k + 1 ].

          (k = i and: [ k <= j ]) ifTrue: [
            v:: v + ((LU at: k) at: j) ].

          diff:: (((LUSave at: i) at: j) - v) abs.
          diff > maxDiff ifTrue: [
            maxDiff:: diff ] ] ].
      maxDiff println.

      ^ maxDiff <= 0.00001
    )

The problem is likely in the parser, which finds the local variable and doesn't check that the variable isn't writable.

smarr avatar Dec 05 '17 20:12 smarr