Let a file without main be checked as a module
Editor diagnostics and 'rex check' no longer report a missing main: the file may be a module other files import. 'rex build' and 'rex run' still need it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
36eacc0011
commit
9b496a7b03
4 files changed
+55
-5
No files matched your search
@@ -81,6 +81,18 @@ fn errors_show_up_as_diagnostics() {
|
||||
assert!(d[0].get("message").and_then(Json::as_str).unwrap().contains("string"), "{:?}", d[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_module_without_main_has_no_errors() {
|
||||
// a file that other files import doesn't need `main`; its other errors still show
|
||||
let module = "pub func double(n: int): int {\n return n * 2\n}\n";
|
||||
let broken = "pub func double(n: int): int {\n return \"no\"\n}\n";
|
||||
let mut msgs = vec![open("file:///tmp/rex-lsp-test/m.rex", module), open("file:///tmp/rex-lsp-test/n.rex", broken)];
|
||||
msgs.extend(exit_messages());
|
||||
let (out, _) = talk(msgs);
|
||||
assert_eq!(out[0].path(&["params", "diagnostics"]), Some(&Json::Arr(vec![])), "{:?}", out[0]);
|
||||
assert_eq!(out[1].path(&["params", "diagnostics"]).map(|d| matches!(d, Json::Arr(a) if a.len() == 1)), Some(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fixing_the_code_clears_the_diagnostics() {
|
||||
let uri = "file:///tmp/rex-lsp-test/b.rex";
|
||||
|
||||
Reference in new issue
Block a user