-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/codegen typechecker correctness #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0fe1ce7
70d6828
4663fdd
b992c0c
884b8ea
6cbb996
1987d55
7a2457b
0590350
455f47f
61c7b32
2af3e94
40fd099
904a432
15297b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,5 @@ coverage.html | |
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| .sisyphus | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,6 +236,66 @@ Get character at index. | |
| char_at("hello", 1) // 'e' | ||
| ``` | ||
|
|
||
| ## Parsing | ||
|
|
||
| ### `parse_int(str) -> int` | ||
| Parse a string as an integer. | ||
|
|
||
| ```carv | ||
| parse_int("42") // 42 | ||
| parse_int("-10") // -10 | ||
| ``` | ||
|
|
||
| ### `parse_float(str) -> float` | ||
| Parse a string as a float. | ||
|
|
||
| ```carv | ||
| parse_float("3.14") // 3.14 | ||
| parse_float("2.0") // 2 | ||
| ``` | ||
|
Comment on lines
+249
to
+255
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor inconsistency in example output comment. The comment on line 254 shows ```carv
parse_float("3.14") // 3.14
-parse_float("2.0") // 2
+parse_float("2.0") // 2.0In |
||
|
|
||
| ## Process & Environment | ||
|
|
||
| ### `args() -> array` | ||
| Get command-line arguments passed to the script. | ||
|
|
||
| ```carv | ||
| let a = args(); | ||
| print(a); // ["arg1", "arg2", ...] | ||
| ``` | ||
|
|
||
| ### `exec(command, ...args) -> int` | ||
| Run an external command. Returns the exit code. | ||
|
|
||
| ```carv | ||
| let code = exec("echo", "hello"); // prints "hello", returns 0 | ||
| ``` | ||
|
|
||
| ### `exec_output(command, ...args) -> Result` | ||
| Run an external command and capture output. Returns `Ok(stdout)` or `Err(stderr)`. | ||
|
|
||
| ```carv | ||
| let result = exec_output("echo", "hello"); | ||
| match result { | ||
| Ok(out) => print(trim(out)), | ||
| Err(e) => print("failed: " + e), | ||
| } | ||
| ``` | ||
|
|
||
| ### `getenv(key) -> string` | ||
| Get an environment variable. Returns empty string if not set. | ||
|
|
||
| ```carv | ||
| let home = getenv("HOME"); | ||
| ``` | ||
|
|
||
| ### `setenv(key, value)` | ||
| Set an environment variable. | ||
|
|
||
| ```carv | ||
| setenv("MY_VAR", "hello"); | ||
| ``` | ||
|
|
||
| ## File I/O | ||
|
|
||
| ### `read_file(path) -> string` | ||
|
|
@@ -252,6 +312,13 @@ Write string to file. | |
| write_file("out.txt", "hello"); | ||
| ``` | ||
|
|
||
| ### `append_file(path, content)` | ||
| Append string to file. Creates the file if it doesn't exist. | ||
|
|
||
| ```carv | ||
| append_file("log.txt", "new line\n"); | ||
| ``` | ||
|
|
||
| ### `file_exists(path) -> bool` | ||
| Check if file exists. | ||
|
|
||
|
|
@@ -261,6 +328,13 @@ if file_exists("config.txt") { | |
| } | ||
| ``` | ||
|
|
||
| ### `mkdir(path)` | ||
| Create a directory (and parent directories). | ||
|
|
||
| ```carv | ||
| mkdir("build/output"); | ||
| ``` | ||
|
|
||
| ## Control Flow | ||
|
|
||
| ### `exit(code?)` | ||
|
|
@@ -278,6 +352,21 @@ Crash with error message. | |
| panic("something went wrong"); | ||
| ``` | ||
|
|
||
| ## Ownership | ||
|
|
||
| ### `clone(value) -> value` | ||
| Deep copy of any move type (string, array, map, or class instance). | ||
|
|
||
| ```carv | ||
| let original = "hello"; | ||
| let copy = original.clone(); | ||
| print(original); // OK: "hello" | ||
| print(copy); // OK: "hello" | ||
|
|
||
| let arr = [1, 2, 3]; | ||
| let arr_copy = arr.clone(); | ||
| ``` | ||
|
Comment on lines
+355
to
+368
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent The header declares 🤖 Prompt for AI Agents |
||
|
|
||
| --- | ||
|
|
||
| [← Architecture](architecture.md) | **Built-ins** | [Contributing →](../CONTRIBUTING.md) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix moved-value usage in the ownership quick-look example.
Line 53 calls
s.clone()aftershas been moved on Line 52, which should be invalid. Clone the valid binding instead (or clone before the move).✅ Suggested fix
🤖 Prompt for AI Agents