Skip to content

list comprehensions do not check the sequence they iterate over #38

@bennn

Description

@bennn

All for loops check that the loop variable has the right type. That's good.

List comprehensions do not check that the variable they dereference has the right type.

Example program:

def f(xs:List(Int)):
  for x in xs:
    pass
  [x for x in xs]
  return

The retic -p version does a check_type_int inside the for loop, but not inside the comprehension.

from retic.runtime import *
from retic.transient import *
from retic.typing import *

def f(xs):
    check_type_list(xs)
    for x in xs:
        check_type_int(x)
        pass
    check_type_list([x for x in xs])
    return
f = check_type_function(f)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions