diff options
| author | mryouse | 2022-06-26 00:51:02 +0000 |
|---|---|---|
| committer | mryouse | 2022-06-26 00:51:02 +0000 |
| commit | c2bd45ad560f41225fc10f5f5475aba1ace7d25d (patch) | |
| tree | 4f2565aecfc2d69458736c2d308a04d0823a8a05 /neb/__init__.py | |
| parent | 35910fa0ce5ecaa8888c3fd5a0f45ea38b9efbe3 (diff) | |
add return type annotations (just decoration now)
Diffstat (limited to 'neb/__init__.py')
| -rw-r--r-- | neb/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/neb/__init__.py b/neb/__init__.py index f5574d1..4ae32a6 100644 --- a/neb/__init__.py +++ b/neb/__init__.py @@ -47,13 +47,14 @@ class Function: self.args = args self.many = many self.type_ = TypeEnum.ANY # TODO no it's not + self.return_type = Type(":any") def describe(self, name=None): if name is None: name = self.name out = [f"({name}"] out.append(string_args(self.args, self.many)) - return " ".join(out).strip() + ")" + return " ".join(out).strip() + f") {self.return_type}" def arity_check(self, symbol, params): min_arity = len([a for a in self.args if not a.optional]) @@ -115,7 +116,7 @@ class UserFunction(Function): super().__init__(name, newparams, body, args, many) def __str__(self): - out = f"(func {self.name} (" + out = f"(func {self.name} {self.return_type} (" args_list = [f"{a.name} {a.type_}" for a in self.args] if self.many: args_list.append(f"{self.many.name} {self.many.type_}") |
