reticulated icon indicating copy to clipboard operation
reticulated copied to clipboard

list comprehensions do not check the sequence they iterate over

Open bennn opened this issue 7 years ago • 0 comments

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)

bennn avatar May 24 '17 18:05 bennn