Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion effectful/ops/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections.abc import Callable
from typing import Any

from effectful.ops.syntax import _CustomSingleDispatchCallable, defop
from effectful.ops.syntax import _CustomSingleDispatchCallable, defdata, defop
from effectful.ops.types import (
Expr,
Interpretation,
Expand Down Expand Up @@ -364,6 +364,7 @@ def _update_fvs(op, *args, **kwargs):
assert isinstance(bound_var, Operation)
if bound_var in _fvs:
_fvs.remove(bound_var)
return defdata(op, *args, **kwargs)

with interpreter({apply: _update_fvs}):
evaluate(term)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_ops_semantics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import dataclasses
import functools
import itertools
import logging
Expand Down Expand Up @@ -863,3 +864,16 @@ def get_mixed() -> Literal[1, "a"]:

with pytest.raises(TypeError, match="Union types are not supported"):
typeof(get_mixed())


def test_fvsof_dataclass() -> None:
@dataclasses.dataclass
class A:
x: int

def __init__(self, x: int):
assert x is not None
self.x = x

v = Operation.define(int)
assert fvsof(A(v())) == {v}
Loading