aboutsummaryrefslogtreecommitdiff
path: root/neb/__init__.py
diff options
context:
space:
mode:
authormryouse2022-06-22 04:03:13 +0000
committermryouse2022-06-22 04:03:13 +0000
commit810d01108110901a290aa4d4a9cdf96187430d0d (patch)
tree4d8b1142e70b0c08426644ac35319febacb88228 /neb/__init__.py
parent7e69cf2d253ba12055b827c584380438e2e0a70f (diff)
initial commit of user defined types!
Diffstat (limited to 'neb/__init__.py')
-rw-r--r--neb/__init__.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/neb/__init__.py b/neb/__init__.py
index c505a04..16d5e44 100644
--- a/neb/__init__.py
+++ b/neb/__init__.py
@@ -143,11 +143,10 @@ class UserFunction(Function):
args.append(Arg(param.name, TypeEnum.ANY))
prev_type = False
elif isinstance(param, Type) and not prev_type and not first:
- typ = TypeEnum.__getattr__(param.name[1:].upper())
if many is None:
- args[-1].type_ = typ
+ args[-1].type_ = param.name
else:
- many.type_ = typ
+ many.type_ = param.name
prev_type = True
else:
raise NebPanic("invalid :func signature", param)
@@ -164,7 +163,6 @@ class UserFunction(Function):
# if we got "many", wrap the rest in a list
if self.many:
this_env.register(self.many.name, List(evaluated_args[len(self.params):]))
-
return interpret(self.body, env=this_env, ns=ns)
@@ -176,7 +174,10 @@ class TypeWrap:
self.is_func = is_func
def validate_type(self, target, env, ns):
- valid = self.is_func(None, [target], env, ns)
+ # if it's an any type, it's valid
+ if self.parent is None:
+ return Bool(True)
+ valid = self.is_func.call(List([None, target]), env, ns)
if valid.value == True:
return valid
parent_type = env.get(f"{target.type_}")