Skip to content

Commit

Permalink
Merge pull request #336 from koto-lang/various-tweaks
Browse files Browse the repository at this point in the history
Various tweaks
  • Loading branch information
irh authored Jun 3, 2024
2 parents c8b8234 + f9005f4 commit 1e0f5a6
Show file tree
Hide file tree
Showing 24 changed files with 397 additions and 323 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions crates/bytecode/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::{
};
use derive_name::VariantName;
use koto_parser::{
Ast, AstBinaryOp, AstFor, AstIf, AstIndex, AstNode, AstTry, AstUnaryOp, ChainNode,
Ast, AstBinaryOp, AstFor, AstIf, AstIndex, AstNode, AstTry, AstUnaryOp, AstVec, ChainNode,
ConstantIndex, Function, ImportItem, MatchArm, MetaKeyId, Node, Span, StringContents,
StringFormatOptions, StringNode, SwitchArm,
};
use smallvec::SmallVec;
use smallvec::{smallvec, SmallVec};
use thiserror::Error;

/// The different error types that can be thrown by the Koto runtime
Expand Down Expand Up @@ -2589,7 +2589,7 @@ impl Compiler {
if piped_arg_register.is_some() {
let piped_call_args = match last_node {
ChainNode::Call { args, with_parens } if !with_parens => args,
_ => Vec::new(),
_ => AstVec::new(),
};

let (parent_register, function_register) = match &node_registers.as_slice() {
Expand Down Expand Up @@ -3095,15 +3095,15 @@ impl Compiler {

None
}
Node::Wildcard(..) => Some(vec![*arm_pattern]),
Node::Wildcard(..) => Some(smallvec![*arm_pattern]),
_ => {
if match_len != 1 {
return self.error(ErrorKind::UnexpectedMatchPatternCount {
expected: match_len,
unexpected: 1,
});
}
Some(vec![*arm_pattern])
Some(smallvec![*arm_pattern])
}
};

Expand Down
22 changes: 11 additions & 11 deletions crates/cli/docs/core_lib/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A collection of utilities for working with the local filesystem.
## create

```kototype
|String| -> File
|path: String| -> File
```

Returns an empty `File` at the provided path.
Expand Down Expand Up @@ -36,7 +36,7 @@ directory can't be retrieved.
## exists

```kototype
|String| -> Bool
|path: String| -> Bool
```

Returns true if a file exists at the provided path.
Expand All @@ -56,7 +56,7 @@ io.exists path
## extend_path

```kototype
|String, Value...| -> String
|path: String, nodes: Any...| -> String
```

Takes an initial path as a string, and extends it with the provided nodes,
Expand All @@ -77,7 +77,7 @@ io.extend_path ".", "foo", "bar", "baz.txt"
## open

```kototype
|String| -> File
|path: String| -> File
```

Opens the file at the given path, and returns a corresponding `File`.
Expand All @@ -98,13 +98,13 @@ f.exists()

```kototype
```kototype
|Value| -> Null
|Any| -> Null
```

Prints a single value to the active output.

```kototype
|Value, Value...| -> Null
|Any, Any...| -> Null
```

Prints a series of values to the active output as a tuple.
Expand All @@ -118,7 +118,7 @@ Prints a series of values to the active output as a tuple.
## read_to_string

```kototype
|String| -> String
|path: String| -> String
```

Returns a string containing the contents of the file at the given path.
Expand All @@ -142,7 +142,7 @@ io.read_to_string "foo.temp"
## remove_file

```kototype
|String| -> Null
|path: String| -> Null
```

Removes the file at the given path.
Expand Down Expand Up @@ -289,23 +289,23 @@ An error is thrown if the file doesn't contain valid UTF-8 data.
## File.seek

```kototype
|File, Number| -> Null
|File, position: Number| -> Null
```

Seeks within the file to the specified position in bytes.

## File.write

```kototype
|File, Value| -> Null
|File, Any| -> Null
```

Writes the formatted value as a string to the file.

## File.write_line

```kototype
|File, Value| -> Null
|File, Any| -> Null
```

Writes the formatted value as a string, with a newline, to the file.
Loading

0 comments on commit 1e0f5a6

Please sign in to comment.