diff --git a/Cargo.lock b/Cargo.lock index c05f506..d330b42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ [[package]] name = "comline-codegen" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=d88f731f8211b80cec6a82272aa61aa5140a0775#d88f731f8211b80cec6a82272aa61aa5140a0775" +source = "git+https://github.com/ComlineProject/generation?rev=9b101080133da8f26747c1322dd8959e6cd973ff#9b101080133da8f26747c1322dd8959e6cd973ff" dependencies = [ "comline-core", "eyre", @@ -409,7 +409,7 @@ dependencies = [ [[package]] name = "comline-codegen-rust" version = "0.1.0" -source = "git+https://github.com/ComlineProject/comline-rust?rev=4b21074d56b005ed8500bcc31bcaf8aebec215e2#4b21074d56b005ed8500bcc31bcaf8aebec215e2" +source = "git+https://github.com/ComlineProject/comline-rust?rev=562084f595a8f529210f0169c4e3f6855cfdd8c3#562084f595a8f529210f0169c4e3f6855cfdd8c3" dependencies = [ "comline-codegen", "comline-core", @@ -419,7 +419,7 @@ dependencies = [ [[package]] name = "comline-codegen-typescript" version = "0.1.0" -source = "git+https://github.com/ComlineProject/comline-typescript?rev=a8424c623170aa0fec6363513d354d0dba23c060#a8424c623170aa0fec6363513d354d0dba23c060" +source = "git+https://github.com/ComlineProject/comline-typescript?rev=a5a8800dd1c3d245ae53e7862b4ee218f36eadfd#a5a8800dd1c3d245ae53e7862b4ee218f36eadfd" dependencies = [ "comline-codegen", "comline-core", @@ -429,7 +429,7 @@ dependencies = [ [[package]] name = "comline-core" version = "0.1.0" -source = "git+https://github.com/ComlineProject/core?rev=a3f9eef50c939b4cd5e7563f96d67c8db4012747#a3f9eef50c939b4cd5e7563f96d67c8db4012747" +source = "git+https://github.com/ComlineProject/core?rev=a5d6f8597c8c2f4ac44ae9feabfdfbb4bb671e82#a5d6f8597c8c2f4ac44ae9feabfdfbb4bb671e82" dependencies = [ "ariadne", "blake3", @@ -456,7 +456,7 @@ dependencies = [ [[package]] name = "comline-core-stdlib" version = "0.1.0" -source = "git+https://github.com/ComlineProject/core?rev=a3f9eef50c939b4cd5e7563f96d67c8db4012747#a3f9eef50c939b4cd5e7563f96d67c8db4012747" +source = "git+https://github.com/ComlineProject/core?rev=a5d6f8597c8c2f4ac44ae9feabfdfbb4bb671e82#a5d6f8597c8c2f4ac44ae9feabfdfbb4bb671e82" [[package]] name = "concolor" diff --git a/Cargo.toml b/Cargo.toml index 8654179..963b409 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,15 +32,15 @@ eyre = "0.6.8" # needs real I/O (git fetch, filesystem), so it's off by default for # `comline-core`'s wasm32 consumers (the playground editor, the language # server); the CLI is the one consumer that actually runs `comline build`. -comline-core = { git = "https://github.com/ComlineProject/core", rev = "a3f9eef50c939b4cd5e7563f96d67c8db4012747", features = ["deps"] } +comline-core = { git = "https://github.com/ComlineProject/core", rev = "a5d6f8597c8c2f4ac44ae9feabfdfbb4bb671e82", features = ["deps"] } # All three pinned to revs that agree on one `comline-codegen`, and bumped # together: comline-rust and comline-typescript's codegen crates consume # `comline-codegen`'s types, so the rev below must be byte-identical to the # one *they* pin - Cargo only unifies a git dependency across identical rev # strings, and two copies of `GenRequest` are two incompatible types. -comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "d88f731f8211b80cec6a82272aa61aa5140a0775" } -comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "4b21074d56b005ed8500bcc31bcaf8aebec215e2", optional = true } -comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "a8424c623170aa0fec6363513d354d0dba23c060", optional = true } +comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "9b101080133da8f26747c1322dd8959e6cd973ff" } +comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "562084f595a8f529210f0169c4e3f6855cfdd8c3", optional = true } +comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "a5a8800dd1c3d245ae53e7862b4ee218f36eadfd", optional = true } [features] # Which language generators are compiled in. Drop one to shed its whole diff --git a/src/lang_targets.rs b/src/lang_targets.rs index c99cfa0..b61391a 100644 --- a/src/lang_targets.rs +++ b/src/lang_targets.rs @@ -212,6 +212,12 @@ pub fn check_declared(context: &ProjectContext, registry: &Registry) -> eyre::Re } } + // JSON-RPC protocols on one connection whose bare method names a side + // couldn't tell apart: no generator can emit them. + for clash in comline_codegen::connections::bare_name_clashes(&schemas, None) { + problems.push(format!("every target: {clash}")); + } + if problems.is_empty() { Ok(warnings) } else { diff --git a/tests/cli/build.rs b/tests/cli/build.rs index f02b350..4bb4186 100644 --- a/tests/cli/build.rs +++ b/tests/cli/build.rs @@ -129,3 +129,31 @@ fn refuses_a_declaration_below_a_dependencys() { "`rust#1.85.0` is older than dependency `shared` allows: it declares `rust#1.90.0`", )); } + +#[test] +fn refuses_bare_jsonrpc_names_that_would_clash_on_a_connection() { + let allow_framing = "\nsettings = {\n annotations = {\n framing = {\n allowed = true\n }\n }\n}\n"; + let schema = |admin_framing: &str| { + format!( + "@framing = \"jsonrpc\"\nprotocol Chat {{\n function send(text: string) -> u64;\n}}\n\n\ + @framing = {admin_framing}\nprotocol Admin {{\n function send(text: string) -> u64;\n}}\n\n\ + @provider = Client\n@framing = \"jsonrpc\"\nprotocol Events {{\n function ping();\n}}\n" + ) + }; + + let temp = tempfile::tempdir().unwrap(); + let project = declaring(temp.path(), "rust#1.85.0 = {}", allow_framing); + std::fs::write(project.join("src/link.ids"), schema("\"jsonrpc\"")).unwrap(); + build(&project).failure().stderr(predicate::str::contains( + "every target: protocols `link::Chat` and `link::Admin` both have a function `send`", + )); + assert!(!project.join(".comline").exists(), "nothing was frozen"); + + // Qualified, the two `send`s are told apart. + std::fs::write( + project.join("src/link.ids"), + schema("{ name = \"jsonrpc\", method_names = qualified }"), + ) + .unwrap(); + build(&project).success(); +}