Skip to content

Commit 6a0eb80

Browse files
authored
Merge branch 'main' into ignore-ctrl-c-in-repl
2 parents 2014221 + 6c846a5 commit 6a0eb80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1645
-1365
lines changed

Diff for: Cargo.lock

+20-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ members = [
2929
"crates/wasm_module",
3030
"crates/wasm_interp",
3131
"crates/language_server",
32+
"crates/roc_std_heap",
3233
]
3334

3435
exclude = [

Diff for: README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ You can 💜 **sponsor** 💜 Roc on:
1919
- [GitHub](https://github.com/sponsors/roc-lang)
2020
- [Liberapay](https://liberapay.com/roc_lang)
2121

22-
We are very grateful for our corporate sponsors [Vendr](https://www.vendr.com/), [RWX](https://www.rwx.com), [Tweede golf](https://tweedegolf.nl/en), [ohne-makler](https://www.ohne-makler.net), and [Decem](https://www.decem.com.au):
22+
We are very grateful for our corporate sponsors [Tweede golf](https://tweedegolf.nl/en), [ohne-makler](https://www.ohne-makler.net), and [Decem](https://www.decem.com.au):
2323

24-
[<img src="https://user-images.githubusercontent.com/1094080/223597445-81755626-a080-4299-a38c-3c92e7548489.png" height="60" alt="Vendr logo"/>](https://www.vendr.com)
25-
&nbsp;&nbsp;&nbsp;&nbsp;
26-
[<img src="https://github.com/roc-lang/roc/assets/1094080/82c0868e-d23f-42a0-ac2d-c6e6b2e16575" height="60" alt="RWX logo"/>](https://www.rwx.com)
27-
&nbsp;&nbsp;&nbsp;&nbsp;
2824
[<img src="https://user-images.githubusercontent.com/1094080/183123052-856815b1-8cc9-410a-83b0-589f03613188.svg" height="60" alt="tweede golf logo"/>](https://tweedegolf.nl/en)
2925
&nbsp;&nbsp;&nbsp;&nbsp;
3026
[<img src="https://www.ohne-makler.net/static/img/brand/logo.svg" height="60" alt="ohne-makler logo"/>](https://www.ohne-makler.net)
@@ -35,6 +31,7 @@ If you would like your company to become a corporate sponsor of Roc's developmen
3531

3632
We'd also like to express our gratitude to our generous [individual sponsors](https://github.com/sponsors/roc-lang/)! A special thanks to those sponsoring $25/month or more:
3733

34+
- [Peter Marreck](https://github.com/pmarreck)
3835
- [Barry Moore](https://github.com/chiroptical)
3936
- Eric Andresen
4037
- [Jackson Lucky](https://github.com/jluckyiv)

Diff for: crates/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Surgical linker that links platforms to Roc applications. We created our own lin
8686

8787
## `repl_cli/` - `roc_repl_cli`
8888

89-
Command Line Interface(CLI) functionality for the Read-Evaluate-Print-Loop (REPL).
89+
Command Line Interface (CLI) functionality for the Read-Evaluate-Print-Loop (REPL).
9090

9191
## `repl_eval/` - `roc_repl_eval`
9292

Diff for: crates/cli/src/format.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,23 @@ mod tests {
266266
const FORMATTED_ROC: &str = r#"app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br" }
267267
268268
import pf.Stdout
269-
import pf.Task
269+
import pf.Stdin
270270
271271
main =
272-
Stdout.line! "I'm a Roc application!""#;
272+
Stdout.line! "What's your name?"
273+
name = Stdin.line!
274+
Stdout.line! "Hi $(name)!""#;
273275

274276
const UNFORMATTED_ROC: &str = r#"app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br" }
275277
276278
277279
import pf.Stdout
278-
279-
import pf.Task
280+
import pf.Stdin
280281
281282
main =
282-
Stdout.line! "I'm a Roc application!"
283+
Stdout.line! "What's your name?"
284+
name = Stdin.line!
285+
Stdout.line! "Hi $(name)!"
283286
"#;
284287

285288
fn setup_test_file(dir: &Path, file_name: &str, contents: &str) -> PathBuf {

Diff for: crates/cli/src/lib.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ pub const FLAG_NO_LINK: &str = "no-link";
6969
pub const FLAG_TARGET: &str = "target";
7070
pub const FLAG_TIME: &str = "time";
7171
pub const FLAG_VERBOSE: &str = "verbose";
72+
pub const FLAG_NO_COLOR: &str = "no-color";
73+
pub const FLAG_NO_HEADER: &str = "no-header";
7274
pub const FLAG_LINKER: &str = "linker";
7375
pub const FLAG_PREBUILT: &str = "prebuilt-platform";
7476
pub const FLAG_CHECK: &str = "check";
@@ -271,6 +273,20 @@ pub fn build_app() -> Command {
271273
)
272274
.subcommand(Command::new(CMD_REPL)
273275
.about("Launch the interactive Read Eval Print Loop (REPL)")
276+
.arg(
277+
Arg::new(FLAG_NO_COLOR)
278+
.long(FLAG_NO_COLOR)
279+
.help("Do not use any ANSI color codes in the repl output")
280+
.action(ArgAction::SetTrue)
281+
.required(false)
282+
)
283+
.arg(
284+
Arg::new(FLAG_NO_HEADER)
285+
.long(FLAG_NO_HEADER)
286+
.help("Do not print the repl header")
287+
.action(ArgAction::SetTrue)
288+
.required(false)
289+
)
274290
)
275291
.subcommand(Command::new(CMD_RUN)
276292
.about("Run a .roc file even if it has build errors")
@@ -1279,8 +1295,8 @@ fn roc_dev_native(
12791295
break if libc::WIFEXITED(status) {
12801296
libc::WEXITSTATUS(status)
12811297
} else {
1282-
// we don't have an exit code, so we probably shouldn't make one up
1283-
0
1298+
// we don't have an exit code, but something went wrong if we're in this else
1299+
1
12841300
};
12851301
}
12861302
ChildProcessMsg::Expect => {

Diff for: crates/cli/src/main.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use roc_cli::{
66
build_app, format_files, format_src, test, BuildConfig, FormatMode, CMD_BUILD, CMD_CHECK,
77
CMD_DEV, CMD_DOCS, CMD_FORMAT, CMD_GEN_STUB_LIB, CMD_GLUE, CMD_PREPROCESS_HOST, CMD_REPL,
88
CMD_RUN, CMD_TEST, CMD_VERSION, DIRECTORY_OR_FILES, FLAG_CHECK, FLAG_DEV, FLAG_LIB, FLAG_MAIN,
9-
FLAG_NO_LINK, FLAG_OUTPUT, FLAG_PP_DYLIB, FLAG_PP_HOST, FLAG_PP_PLATFORM, FLAG_STDIN,
10-
FLAG_STDOUT, FLAG_TARGET, FLAG_TIME, GLUE_DIR, GLUE_SPEC, ROC_FILE,
9+
FLAG_NO_COLOR, FLAG_NO_HEADER, FLAG_NO_LINK, FLAG_OUTPUT, FLAG_PP_DYLIB, FLAG_PP_HOST,
10+
FLAG_PP_PLATFORM, FLAG_STDIN, FLAG_STDOUT, FLAG_TARGET, FLAG_TIME, GLUE_DIR, GLUE_SPEC,
11+
ROC_FILE,
1112
};
1213
use roc_docs::generate_docs_html;
1314
use roc_error_macros::user_error;
@@ -242,7 +243,12 @@ fn main() -> io::Result<()> {
242243
}
243244
}
244245
}
245-
Some((CMD_REPL, _)) => Ok(roc_repl_cli::main()),
246+
Some((CMD_REPL, matches)) => {
247+
let has_color = !matches.get_one::<bool>(FLAG_NO_COLOR).unwrap();
248+
let has_header = !matches.get_one::<bool>(FLAG_NO_HEADER).unwrap();
249+
250+
Ok(roc_repl_cli::main(has_color, has_header))
251+
}
246252
Some((CMD_DOCS, matches)) => {
247253
let root_path = matches.get_one::<PathBuf>(ROC_FILE).unwrap();
248254
let out_dir = matches.get_one::<OsString>(FLAG_OUTPUT).unwrap();

Diff for: crates/cli/tests/cli_run.rs

+19
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,25 @@ mod cli_run {
922922
);
923923
}
924924

925+
#[test]
926+
#[cfg_attr(windows, ignore)]
927+
fn module_params_multiline_pattern() {
928+
test_roc_app(
929+
"crates/cli/tests/module_params",
930+
"multiline_params.roc",
931+
&[],
932+
&[],
933+
&[],
934+
indoc!(
935+
r#"
936+
hi
937+
"#
938+
),
939+
UseValgrind::No,
940+
TestCliCommands::Dev,
941+
);
942+
}
943+
925944
#[test]
926945
#[cfg_attr(windows, ignore)]
927946
fn transitive_expects() {

Diff for: crates/cli/tests/module_params/MultilineParams.roc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module {
2+
sendHttpReq,
3+
getEnvVar
4+
} -> [hi]
5+
6+
hi : Str
7+
hi =
8+
"hi"

Diff for: crates/cli/tests/module_params/multiline_params.roc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
app [main] {
2+
pf: platform "../fixtures/multi-dep-str/platform/main.roc",
3+
}
4+
5+
import MultilineParams {
6+
sendHttpReq: \_ -> crash "todo",
7+
getEnvVar: \_ -> crash "todo",
8+
}
9+
10+
main =
11+
MultilineParams.hi

Diff for: crates/compiler/builtins/bitcode/src/list.zig

+18-17
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,16 @@ pub fn listDropAt(
618618
) callconv(.C) RocList {
619619
const size = list.len();
620620
const size_u64 = @as(u64, @intCast(size));
621+
622+
// NOTE
623+
// we need to return an empty list explicitly,
624+
// because we rely on the pointer field being null if the list is empty
625+
// which also requires duplicating the utils.decref call to spend the RC token
626+
if (size <= 1) {
627+
list.decref(alignment, element_width, elements_refcounted, dec);
628+
return RocList.empty();
629+
}
630+
621631
// If droping the first or last element, return a seamless slice.
622632
// For simplicity, do this by calling listSublist.
623633
// In the future, we can test if it is faster to manually inline the important parts here.
@@ -638,25 +648,16 @@ pub fn listDropAt(
638648
// were >= than `size`, and we know `size` fits in usize.
639649
const drop_index: usize = @intCast(drop_index_u64);
640650

641-
if (elements_refcounted) {
642-
const element = source_ptr + drop_index * element_width;
643-
dec(element);
644-
}
645-
646-
// NOTE
647-
// we need to return an empty list explicitly,
648-
// because we rely on the pointer field being null if the list is empty
649-
// which also requires duplicating the utils.decref call to spend the RC token
650-
if (size < 2) {
651-
list.decref(alignment, element_width, elements_refcounted, dec);
652-
return RocList.empty();
653-
}
654-
655651
if (list.isUnique()) {
656-
var i = drop_index;
657-
const copy_target = source_ptr;
652+
if (elements_refcounted) {
653+
const element = source_ptr + drop_index * element_width;
654+
dec(element);
655+
}
656+
657+
const copy_target = source_ptr + (drop_index * element_width);
658658
const copy_source = copy_target + element_width;
659-
std.mem.copyForwards(u8, copy_target[i..size], copy_source[i..size]);
659+
const copy_size = (size - drop_index - 1) * element_width;
660+
std.mem.copyForwards(u8, copy_target[0..copy_size], copy_source[0..copy_size]);
660661

661662
var new_list = list;
662663

0 commit comments

Comments
 (0)