Closed amtriathlon closed 11 years ago
In the current implementation filter is a function returning a list, this is not the intended behavior, for example:
filter(42, (1,2))
shouldn't give an error, the error should be generated when we iterate the result, for example:
list(filter(42, (1,2)))
should give a TypeError exception.
In fact, this example is taken from the python-reference/builtin/filter.py test, which is passed only do to this "patch" which hides the problem:
;; very hacky solution for assertRaises: it needs laziness built into it, so instead ;; of defining it as a function, we'll special case it as a macro. [PyApp (fun args) (cond #|[(and (PyId? fun) (symbol=? (PyId-x fun) '___assertRaises)) (local [(define f (rec-desugar (second args) global? env (none))) (define-values (as as-env) (map-desugar (rest (rest args)) global? (DResult-env f) (none))) (define exns (rec-desugar (first args) global? as-env (none))) (define pass (rec-desugar (PyPass) global? (DResult-env exns) (none)))] (DResult (CApp (CFunc empty (none) (CTryExceptElseFinally (CApp (DResult-expr f) as (none)) (list (CExcept (list (DResult-expr exns)) (none) (DResult-expr pass)) (CExcept empty (none) (DResult-expr pass))) (CApp (CId 'print (GlobalId)) (list (make-builtin-str "Assert failure!")) (none)) (DResult-expr pass)) (none)) empty (none)) (DResult-env pass)))]|#
Solved by https://github.com/brownplt/lambda-py/commit/746b12a6bcaa1422eef10ddd77fcd8a700818e29
In the current implementation filter is a function returning a list, this is not the intended behavior, for example:
filter(42, (1,2))
shouldn't give an error, the error should be generated when we iterate the result, for example:
list(filter(42, (1,2)))
should give a TypeError exception.
In fact, this example is taken from the python-reference/builtin/filter.py test, which is passed only do to this "patch" which hides the problem: