Skip to content

Commit

Permalink
small SemLiteral fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EasyArray committed Mar 19, 2022
1 parent d5c4620 commit b5ea7d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion phosphorus/phival.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from numbers import Number
import builtins; import ast
import re; import time

from .parse import Span, errors_on, log, debugging

ip = get_ipython()
Expand Down Expand Up @@ -633,6 +634,10 @@ def type(x):
if x is None:
return ConstantVal('t') # small hack for uninterpretable lambda bodies

from .semval import SemLiteral
if isinstance(x, SemLiteral): # can't check equality of SemLiterals
return ConstantVal("t")

for t in SemType.D:
if x in SemType.D[t]: return ConstantVal(t)

Expand Down Expand Up @@ -816,7 +821,8 @@ def ext(f,domain=map(ConstantVal,SemType.D["e"]),memoize=True):
return out
except Exception as e:
#raise e
return Span.parse(f"ext({f})")
from .semval import SemLiteral
return SemLiteral(f"ext({f})")

def ι(f, domain=None):
try:
Expand Down
4 changes: 4 additions & 0 deletions phosphorus/semval.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def __ror__(self,other):

def __invert__(self): return SpanVal("¬" + self)

# NOTE: a little dangerous, since we basically can't compare SemLiterals
def __eq__(self,other):
return opcode(self, "==", other)

# Since SemLiterals do not have a known value, we don't want them
# short-circuiting boolean "and" and "or" in python.
# We use & and | instead
Expand Down

0 comments on commit b5ea7d7

Please sign in to comment.