Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P001",
"code": "graphcal::W001",
"labels": [
{
"length": 15,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P001",
"code": "graphcal::W001",
"labels": [
{
"length": 8,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P001",
"code": "graphcal::W001",
"labels": [
{
"length": 40,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P001",
"code": "graphcal::W001",
"labels": [
{
"length": 79,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P011",
"code": "graphcal::W011",
"labels": [
{
"length": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P004",
"code": "graphcal::W004",
"labels": [
{
"length": 10,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P003",
"code": "graphcal::W003",
"labels": [
{
"length": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P001",
"code": "graphcal::W001",
"labels": [
{
"length": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P001",
"code": "graphcal::W001",
"labels": [
{
"length": 7,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P002",
"code": "graphcal::W002",
"labels": [
{
"length": 13,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::P001",
"code": "graphcal::W001",
"labels": [
{
"length": 27,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 16,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 10,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 13,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 185,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 14,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 12,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 6,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check": {
"code": "graphcal::M033",
"code": "graphcal::M036",
"labels": [
{
"length": 7,
Expand Down
2 changes: 1 addition & 1 deletion crates/graphcal-compiler/src/semantic_error/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl DiagnosticKind for ModuleError {
Self::IndexBindingNotAnIndex { .. } => "graphcal::M019",
Self::IndexKindMismatch { .. } => "graphcal::M018",
Self::ImportRuntimeItem { .. } => "graphcal::M020",
Self::ModuleResolution { .. } => "graphcal::M033",
Self::ModuleResolution { .. } => "graphcal::M036",
Self::AmbiguousModulePath { .. } => "graphcal::M034",
}
}
Expand Down
20 changes: 10 additions & 10 deletions crates/graphcal-compiler/src/semantic_error/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ pub enum PluginLoadFailure {
impl DiagnosticKind for PluginError {
fn code(&self) -> &'static str {
match self {
Self::UnknownExternFunction { .. } => "graphcal::P002",
Self::InvalidExternSignature { .. } => "graphcal::P001",
Self::DuplicateExternParameter { .. } => "graphcal::P011",
Self::MissingHostFunction { .. } => "graphcal::P003",
Self::ExternCallNotAllowed { .. } => "graphcal::P004",
Self::ExternSignatureMismatch { .. } => "graphcal::P005",
Self::PluginLoadFailed { .. } => "graphcal::P006",
Self::PluginForbiddenImport { .. } => "graphcal::P007",
Self::PluginNotPinned { .. } => "graphcal::P009",
Self::PluginHashMismatch { .. } => "graphcal::P010",
Self::UnknownExternFunction { .. } => "graphcal::W002",
Self::InvalidExternSignature { .. } => "graphcal::W001",
Self::DuplicateExternParameter { .. } => "graphcal::W011",
Self::MissingHostFunction { .. } => "graphcal::W003",
Self::ExternCallNotAllowed { .. } => "graphcal::W004",
Self::ExternSignatureMismatch { .. } => "graphcal::W005",
Self::PluginLoadFailed { .. } => "graphcal::W006",
Self::PluginForbiddenImport { .. } => "graphcal::W007",
Self::PluginNotPinned { .. } => "graphcal::W009",
Self::PluginHashMismatch { .. } => "graphcal::W010",
}
}

Expand Down
16 changes: 7 additions & 9 deletions crates/graphcal-compiler/src/semantic_error/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ fn every_family_contributes_codes_with_its_own_prefix() {
}

#[test]
fn diagnostic_codes_are_unique_and_reassignments_are_pinned() {
fn diagnostic_code_reassignments_are_pinned() {
// Workspace-wide uniqueness is checked by
// `crates/graphcal-project/tests/diagnostic_codes.rs`.
let mut catalog = family_code_catalog();
let internal = crate::internal_error::InternalError::CODE;
catalog.insert(
Expand All @@ -67,13 +69,6 @@ fn diagnostic_codes_are_unique_and_reassignments_are_pinned() {
);
assert!(catalog.len() > 100, "incomplete catalog: {catalog:?}");

let mut variants_by_code = BTreeMap::new();
for (variant, code) in &catalog {
if let Some(previous) = variants_by_code.insert(code, variant) {
panic!("diagnostic code `{code}` is shared by `{previous}` and `{variant}`");
}
}

for (variant, expected) in [
("LinearAlgebraShapeMismatch", "D022"),
("AggregationCardinalityUnknown", "D027"),
Expand All @@ -83,6 +78,9 @@ fn diagnostic_codes_are_unique_and_reassignments_are_pinned() {
("InvalidEpochTimeScaleArgument", "D029"),
("UnsupportedEpochTimeScale", "D030"),
("ImportRuntimeItem", "M020"),
("ModuleResolution", "M036"),
("InvalidExternSignature", "W001"),
("PluginHashMismatch", "W010"),
("InternalError", "X001"),
] {
assert_eq!(catalog.get(variant).map(String::as_str), Some(expected));
Expand Down Expand Up @@ -217,7 +215,7 @@ fn module_resolution_keeps_ambiguous_paths_apart_and_cycles_name_their_templates
let unknown = ModuleError::resolution(ModuleResolveError::UnknownModule {
owner: second.clone(),
});
assert_eq!(unknown.code(), "graphcal::M033");
assert_eq!(unknown.code(), "graphcal::M036");
assert_eq!(
unknown.to_string(),
ModuleResolveError::UnknownModule {
Expand Down
2 changes: 1 addition & 1 deletion crates/graphcal-lsp/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ param event: Datetime<TT>(
assert_eq!(diagnostics.len(), 1, "{diagnostics:?}");
assert!(matches!(
&diagnostics[0].code,
Some(NumberOrString::String(code)) if code == "graphcal::P011"
Some(NumberOrString::String(code)) if code == "graphcal::W011"
));
assert!(diagnostics[0].related_information.is_some());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/graphcal-plugin-host/tests/project_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ node bad: Bool[Item] = scalars::invert(@numbers);
#[test]
fn declared_array_signature_must_match_the_manifest() {
// The declaration says the result reuses the input's index variable but
// over a *different* element dimension — structural mismatch, P005.
// over a *different* element dimension — structural mismatch, W005.
let dir = tempfile::tempdir().unwrap();
let source = r#"
import plugin "plugins/arrays.wasm" as arrays {
Expand Down
6 changes: 3 additions & 3 deletions crates/graphcal-plugin/tests/prelude_drift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! verified against the real thing: for every vocabulary name, a `.gcl`
//! extern declaration spelling that name is compiled against the
//! macro-produced manifest signature. The loader's structural verification
//! (P005) then proves both sides denote the same dimension — if the
//! (W005) then proves both sides denote the same dimension — if the
//! macro's table ever disagrees with the prelude, these tests fail.

#![cfg(test)]
Expand Down Expand Up @@ -153,15 +153,15 @@ fn every_vocabulary_name_matches_the_prelude() {
let dir = tempfile::tempdir().expect("tempdir");
let registry = registry_from_embedded_manifest();
// Structural verification of every declaration against the macro's
// manifest happens during compilation; any table drift is a P005.
// manifest happens during compilation; any table drift is a W005.
compile(dir.path(), GCL_DECLARATIONS, &registry)
.expect("macro vocabulary must match the prelude");
}

#[test]
fn drift_would_be_detected() {
// Negative control: declare one function with the wrong signature and
// require P005, proving the positive test actually verifies signatures.
// require W005, proving the positive test actually verifies signatures.
let dir = tempfile::tempdir().expect("tempdir");
let registry = registry_from_embedded_manifest();
let source = r#"
Expand Down
4 changes: 2 additions & 2 deletions crates/graphcal-project/src/project_compiler/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ pub(super) fn check_hir_project<Mode>(
/// the plugin file must have been read by the loader, and the plugin
/// host must have registered the module (its recorded failure is
/// reported otherwise).
/// 2. The registry must provide the function (`MissingHostFunction`, P003).
/// 2. The registry must provide the function (`MissingHostFunction`, W003).
/// 3. When the registry entry carries a manifest-provided signature, the
/// declared signature must be structurally equivalent to it (P005) —
/// declared signature must be structurally equivalent to it (W005) —
/// this is the "declaration verified against the embedded manifest"
/// guarantee of the plugin design (#25).
fn verify_host_functions(
Expand Down
Loading
Loading