Closed gilch closed 5 years ago
Another example,
test_continue lambda: self:
!let: ijs :be []
self.assertEqual:
()
for: i :in [1,2,3]
for: j :in [1,2,3]
if: (i==j) :then: continue:
ijs.append: [i, j]
self.assertEqual:
[[1, 2],
[1, 3],
[2, 1],
[2, 3],
[3, 1],
[3, 2]]
ijs # Note the extra space here.
test_labeled_continue lambda: self:
!let: ijs :be []
self.assertEqual:
()
for: :top i :in [1,2,3]
for: j :in [1,2,3]
if: (i==j) :then: continue: :top
ijs.append: [i, j]
self.assertEqual:
[[2, 1],
[3, 1],
[3, 2]]
ijs
That barely-noticeable space makes it parse wrong.
If you forget a colon, but indent a block more you should get an error.
Recent example from tests:
Note that
lambda
and the!let
were intended as hotwords and should have colons. The former is valid, sinceself:
gets the block. (Maybe a good reason to spell it aspass:self
instead.) The latter should be an error (but isn't), because it indents the block ofself.assertEqual:
more.