ironpython2
ironpython2 copied to clipboard
In the repl, multi-line statement gives SyntaxError: unexpected token '<newline>'
Prerequisites
- [X] Are you running the latest version?
- [X] Are you reporting to the correct repository?
- [X] Did you perform a cursory search?
Description
IronPython repl gives SyntaxError for multi-line statement within a block. It handles it OK for top-level statements, but not for statements within blocks which are already indented according to python rules. In the below steps, this is within a function definition.
Steps to Reproduce
Attempt to enter the following code in the repl:
def f1(a,b):
return a+b
def f2(a,b,c):
return f1(
f1(a,b),
c)
f2(1,2,3)
Expected behavior: [What you expected to happen] The CPython repl accepts the code:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def f1(a,b):
... return a+b
...
>>> def f2(a,b,c):
... return f1(
... f1(a,b),
... c)
...
>>> f2(1,2,3)
6
>>>
Actual behavior: [What actually happened] The IronPython 2.7.8 repl doesn't accept the code:
IronPython 2.7.8 (2.7.8.0) on .NET 4.0.30319.42000 (64-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> def f1(a,b):
... return a+b
...
>>> def f2(a,b,c):
... return f1(
File "<stdin>", line 3
^
SyntaxError: unexpected token '<newline>'
>>>
Versions
IronPython 2.7.8 2.7.8.0 on .NET 4.0.30319.42000
It also works with the CPython 2.7 repl:
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def f1(a,b):
... return a+b
...
>>> def f2(a,b,c):
... return f1(
... f1(a,b),
... c)
...
>>> f2(1,2,3)
6
>>>
Also happens with eval("\n1")