Skip to content

For loop should be implemented for strings without declaration  #1475

Closed
@faze-geek

Description

@faze-geek

Related to #206 which was closed couple of days ago.

a :str
for a in "abc":
      print (a)

(lp) C:\Users\kunni\lpython>python try.py
a
b
c

(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
semantic error: Only function call `range(..)` supported as for loop iteration for now
 --> try.py:3:5 - 4:17
  |
3 |        for a in "abc":
  |        ^^^^^^^^^^^^^^^...
...
  |
4 |            print (a)
  | ...^^^^^^^^^^^^^^^^^

Considering range is the only supported function, a string input is not another function like reverse(str_name) or enumerate(str_name) so a better error message can be provided if this is not in the implementation plan as of now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions