gilch / hebigo

蛇語(HEH-bee-go): An indentation-based skin for Hissp.
https://github.com/gilch/hissp
Mozilla Public License 2.0
24 stars 3 forks source link

No error for unexpected indent #20

Closed gilch closed 5 years ago

gilch commented 5 years ago

If you forget a colon, but indent a block more you should get an error.

Recent example from tests:

test_default_strs lambda self:
    self.assertEqual:
        ['ab', 22, 33]
        !let
            :=: :strs: a b c
                :default: a ('a'+'b')
            {'b':22,'c':33}
            [a, b, c]

Note that lambda and the !let were intended as hotwords and should have colons. The former is valid, since self: gets the block. (Maybe a good reason to spell it as pass:self instead.) The latter should be an error (but isn't), because it indents the block of self.assertEqual: more.

gilch commented 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.