Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a8abf59
docs(r3): stop lens value authoring for E6-G1
briansrls May 3, 2026
cd9df4a
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
73e80b8
docs(r3): narrow E6 lens value STOP blocker
briansrls May 3, 2026
f04e714
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
2b32834
WIP: silent-deer-861
briansrls May 3, 2026
68dc96e
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
7dd8756
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
58c18ac
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
7fa3126
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
dc75ddf
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
62c4a7f
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
2dc3bfb
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
b8b328b
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
cd357ec
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
692a501
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
0197c36
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
4c26df9
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
3c4b815
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
6e3e4c8
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 3, 2026
cb84fd9
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
1164701
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
218174f
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
774fc84
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
a6de83b
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
a3f863d
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
6730cf4
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
90034a5
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
2526ed7
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
288465a
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
074a461
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
9b9536d
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
9385132
WIP: silent-deer-861
briansrls May 4, 2026
f09b415
chore: apply cargo fmt
briansrls May 4, 2026
3209e25
WIP: silent-deer-861
briansrls May 4, 2026
9edac03
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
e5d1cff
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
be045c7
WIP: silent-deer-861
briansrls May 4, 2026
edaec4e
WIP: silent-deer-861
briansrls May 4, 2026
c2c0553
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
3c23150
WIP: silent-deer-861
briansrls May 4, 2026
aee5eae
Merge remote-tracking branch 'origin/main' into feat/lens-value-autho…
briansrls May 4, 2026
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
97 changes: 97 additions & 0 deletions src/v3/compiler/src/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,103 @@ impl ClusterId {
}
}

/// `std.error_primitives` declares canonical `Result<ok, err> = Ok { value: ok } | Err { value: err }`.
/// Emitters lower it to a target-native `Result` / `struct { Ok; Err }` carrier and must
/// not also emit a second substrate `type Result`.
///
/// Suppression keys off the **resolved structural fingerprint** of that declaration
/// (name + type-parameter identities + `Ok`/`Err` payload wiring), not `span.file`
/// suffixes — so unrelated modules named `errors.dag` cannot collide, and renaming
/// the std file alone does not silently retarget suppression.
///
/// **Policy:** the fingerprint is **global**, not std-scoped: any other declaration
/// named `Result` that matches this exact shape is also suppressed (intentional — the
/// substrate owns one canonical `Result<ok, err>` carrier; a user-defined twin with
/// the same fingerprint would not emit as a separate `type Result`).
pub(crate) fn substrate_result_type_decl_suppressed_for_emit(
dag: &Dag,
decl: &Declaration,
) -> bool {
if decl.name.as_deref() != Some("Result") {
return false;
}
let [ok_param, err_param] = match decl.type_params.as_slice() {
[a, b] => [*a, *b],
_ => return false,
};
let ok_decl = dag.declaration(ok_param);
let err_decl = dag.declaration(err_param);
let ok_param_ok = matches!(
&ok_decl.connective,
TypeConnective::Atom(AtomPayload::TypeParam(name)) if name == "ok"
);
let err_param_ok = matches!(
&err_decl.connective,
TypeConnective::Atom(AtomPayload::TypeParam(name)) if name == "err"
);
if !ok_param_ok || !err_param_ok {
return false;
}
let TypeConnective::Disj { variants } = &decl.connective else {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: Result suppression claims an exact structural fingerprint but accepts any Disj containing Ok and Err, so a Result with extra variants would be suppressed/canonicalized as std despite not matching the substrate carrier (P1 Modeling Faithfulness / P2 Boundary Discipline).

return false;
};
if variants.len() != 2 {
return false;
}
let Some(ok_field) = variants.iter().find(|v| v.label == "Ok") else {
return false;
};
let Some(err_field) = variants.iter().find(|v| v.label == "Err") else {
return false;
};
substrate_result_variant_payload_is_value_of(dag, ok_field.ty, ok_param)
&& substrate_result_variant_payload_is_value_of(dag, err_field.ty, err_param)
}

fn substrate_result_variant_payload_is_value_of(
dag: &Dag,
payload_ty: DeclarationId,
type_param: DeclarationId,
) -> bool {
let payload = dag.declaration(payload_ty);
let TypeConnective::Conj { children } = &payload.connective else {
return false;
};
children.len() == 1 && children[0].label == "value" && children[0].ty == type_param
}

/// `std.error_primitives` declares canonical `DivError = DivideByZero | Overflow`.
/// Like `Result`, emit suppression keys off the resolved structural fingerprint,
/// not the declaration source path. A declaration with this exact global shape is
/// the substrate-owned integer-division error carrier and is materialized by the
/// target division prelude when a program actually needs it.
pub(crate) fn substrate_div_error_type_decl_suppressed_for_emit(
dag: &Dag,
decl: &Declaration,
) -> bool {
if decl.name.as_deref() != Some("DivError") || !decl.type_params.is_empty() {
return false;
}
matches!(&decl.connective, TypeConnective::Disj { variants } if {
variants.len() == 2
&& variants.iter().any(|variant| {
variant.label == "DivideByZero"
&& substrate_div_error_variant_payload_is_unit(dag, variant.ty)
})
&& variants.iter().any(|variant| {
variant.label == "Overflow"
&& substrate_div_error_variant_payload_is_unit(dag, variant.ty)
})
})
}

fn substrate_div_error_variant_payload_is_unit(dag: &Dag, payload_ty: DeclarationId) -> bool {
matches!(
&dag.declaration(payload_ty).connective,
TypeConnective::Conj { children } if children.is_empty()
)
}

/// A type-system declaration. The unit of the type substrate.
///
/// Every named declaration (primitive, algebra, user type, type alias) lives in
Expand Down
Loading
Loading