hedyorg / hedy

Hedy is a gradual programming language to teach children programming. Gradual languages use different language levels, where each level adds new concepts and syntactic complexity. At the end of the Hedy level sequence, kids master a subset of syntactically valid Python.
https://www.hedy.org
European Union Public License 1.2
1.29k stars 284 forks source link

issue with two indents back. Occurs in if in a for loop #363

Closed LauraTSD closed 3 years ago

LauraTSD commented 3 years ago

Test that fails:

  def test_for_ifbug(self):
    code = textwrap.dedent("""\
    for i in range 0 to 10
      antwoord is ask Wat is 5*5
      if antwoord is 24
        print 'fout'
    print 'klaar met for loop'""")

    expected = textwrap.dedent("""\
      for i in range(int(0), int(10)+1):
        antwoord = input('Wat is 5*5')
        if str(antwoord) == str('24'):
          print('fout')
      print('klaar met for loop')""")

    result = hedy.transpile(code, 8)

    self.assertEqual(expected, result)

Gives the following error: image

Occurs from level 8 on.

Does not occur when the last print (klaar met for loop, is in the if or in the for)

Only occurs when the print after the loop gets 2 spaces back.

Felienne commented 3 years ago

Closed by #384