aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/paths.md5
-rw-r--r--src/typecheck.c9
-rw-r--r--test/nums.tm30
-rw-r--r--test/paths.tm4
4 files changed, 26 insertions, 22 deletions
diff --git a/docs/paths.md b/docs/paths.md
index 2bfc9b0f..ac60d864 100644
--- a/docs/paths.md
+++ b/docs/paths.md
@@ -64,7 +64,7 @@ intended. Paths can be created from text with slashes using
- [`func owner(path: Path, follow_symlinks=yes -> Text?)`](#owner)
- [`func parent(path: Path -> Path)`](#parent)
- [`func read(path: Path -> Text?)`](#read)
-- [`func read_bytes(path: Path -> [Byte]?)`](#read_bytes)
+- [`func read_bytes(path: Path, limit: Int? = none -> [Byte]?)`](#read_bytes)
- [`func relative_to(path: Path, relative_to=(./) -> Path)`](#relative_to)
- [`func remove(path: Path, ignore_missing=no -> Void)`](#remove)
- [`func resolved(path: Path, relative_to=(./) -> Path)`](#resolved)
@@ -726,10 +726,11 @@ Reads the contents of the file at the specified path or a null value if the
file could not be read.
```tomo
-func read_bytes(path: Path -> [Byte]?)
+func read_bytes(path: Path, limit: Int? = none -> [Byte]?)
```
- `path`: The path of the file to read.
+- `limit`: A limit to how many bytes should be read.
**Returns:**
The byte contents of the file. If the file cannot be read, a null value will be
diff --git a/src/typecheck.c b/src/typecheck.c
index e4176508..4341748b 100644
--- a/src/typecheck.c
+++ b/src/typecheck.c
@@ -108,12 +108,13 @@ type_t *parse_type_ast(env_t *env, type_ast_t *ast)
arg_t *type_args = NULL;
for (arg_ast_t *arg = fn->args; arg; arg = arg->next) {
type_args = new(arg_t, .name=arg->name, .next=type_args);
- if (arg->type) {
+ if (arg->type)
type_args->type = parse_type_ast(env, arg->type);
- } else {
- type_args->default_val = arg->value;
+ else if (arg->value)
type_args->type = get_type(env, arg->value);
- }
+
+ if (arg->value)
+ type_args->default_val = arg->value;
}
REVERSE_LIST(type_args);
return Type(ClosureType, Type(FunctionType, .args=type_args, .ret=ret_t));
diff --git a/test/nums.tm b/test/nums.tm
index e36ae573..285614d9 100644
--- a/test/nums.tm
+++ b/test/nums.tm
@@ -22,34 +22,36 @@ func main():
>> Num.INF:isinf()
= yes
- >> nan : Num = none
+ >> none_num : Num? = none
= none
- >> nan == nan
+ >> none_num == none_num
= yes
- >> nan < nan
+ >> none_num < none_num
= no
- >> nan > nan
+ >> none_num > none_num
= no
- >> nan != nan
+ >> none_num != none_num
= no
- >> nan <> nan
+ >> none_num <> none_num
= Int32(0)
- >> nan == 0.0
+ >> none_num == 0.0
= no
- >> nan < 0.0
+ >> none_num < 0.0
= yes
- >> nan > 0.0
+ >> none_num > 0.0
= no
- >> nan != 0.0
+ >> none_num != 0.0
= yes
- >> nan <> 0.0
+ >> none_num <> 0.0
= Int32(-1)
- >> nan + 1
- = none
+ # >> nan + 1
+ # = none
>> 0./0.
- = none
+
+ # >> 0./0.
+ # = none
>> Num.PI:cos()!:near(-1)
= yes
diff --git a/test/paths.tm b/test/paths.tm
index 4f053485..72cac24d 100644
--- a/test/paths.tm
+++ b/test/paths.tm
@@ -36,9 +36,9 @@ func main():
fail("Couldn't read lines in $tmpfile")
>> (./does-not-exist.xxx):read()
- = none : Text
+ = none
>> (./does-not-exist.xxx):read_bytes()
- = none : [Byte]
+ = none
if lines := (./does-not-exist.xxx):by_line():
fail("I could read lines in a nonexistent file")
else: