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
Expand Up @@ -463,6 +463,20 @@ impl<'a> DefaultRequirements<'a> {
path: &[StructuralPathSegment],
carrier: StructuralTypeId,
demand: DefaultDemand<'_>,
) -> Judged<Vec<DefaultRequirement>> {
self.at_except(root, path, carrier, demand, &[])
}

/// The default clauses at one place, leaving out the named domains in
/// `delivered`: a whole stored value carries those memberships itself,
/// so they owe no clause and need no storage predicate theory.
fn at_except(
&self,
root: PlaceId,
path: &[StructuralPathSegment],
carrier: StructuralTypeId,
demand: DefaultDemand<'_>,
delivered: &[StructuralDomainId],
) -> Judged<Vec<DefaultRequirement>> {
let mut result = Vec::new();
for position in 0..self.declaration(carrier)?.requires.len() {
Expand All @@ -475,7 +489,7 @@ impl<'a> DefaultRequirements<'a> {
}
let mut named = Vec::new();
for id in self.declared.at(root, path).whole {
named.extend(self.domain_clauses(id, carrier, path, demand)?);
named.extend(self.domain_clauses(id, carrier, path, demand, delivered)?);
}
named.sort_unstable();
named.dedup();
Expand All @@ -495,6 +509,7 @@ impl<'a> DefaultRequirements<'a> {
carrier: StructuralTypeId,
path: &[StructuralPathSegment],
demand: DefaultDemand<'_>,
delivered: &[StructuralDomainId],
) -> Judged<Vec<StructuralDomainId>> {
let mut named = Vec::new();
let row = self
Expand All @@ -510,6 +525,9 @@ impl<'a> DefaultRequirements<'a> {
.required_domain_closure(self.domains)
.ok_or_else(|| self.error("a named default has incomplete membership requirements"))?;
for domain in closure {
if delivered.contains(&domain.id) {
continue;
}
// Snapshot demand names predicate operands. Restoring storage additionally
// owes the value's content, which predicate clauses cannot establish.
if !domain.complete_predicate_theory
Expand Down Expand Up @@ -649,6 +667,7 @@ impl<'a> DefaultRequirements<'a> {
leaf,
&qualified.path,
demand,
&[],
)?
.is_empty();
}
Expand Down Expand Up @@ -1043,11 +1062,12 @@ impl<'a> DefaultRequirements<'a> {
) -> Judged<()> {
let displayed = self.declared.at(displayed_root, displayed_path);
let lost = self
.at(
.at_except(
root,
path,
self.carrier(root, path)?,
DefaultDemand::Restoration,
&displayed.whole,
)?
.into_iter()
.filter(|required| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,55 @@ fn inventory_keeps_a_content_domains_predicate_without_proving_a_changed_value()
);
}

/// A whole stored value carries the content domain its destination displays,
/// so the lender owes no predicate for it (allocation's `bump.omg` stores a
/// split's `rest` into its `@mutable` strategy's `tail`). Under a destination
/// that does not display the domain, the lender's content still owes a proof.
#[test]
fn a_whole_stored_value_delivers_the_content_domain_its_destination_displays() {
use semantic_vocabulary::{
ContentAlgebra, ContentAlgebraKind, ContentDomainId, ContentProjectionExpression,
ContentProjectionIdentity, ContentProjectionScalar,
};
let types = types(2);
let mut machine = machine();
let mut owner = domain(types[1].id);
owner.predicate.as_mut().unwrap().proposition = Proposition::Truth;
machine.structural_parameters[0]
.qualifications
.push(owner.id);
let algebra = ContentAlgebra {
kind: ContentAlgebraKind::CountedQuantity,
parameter: "Bytes".into(),
};
let value =
ContentProjectionExpression::CountedQuantity(ContentProjectionScalar::Natural("2".into()));
owner.content_projection = Some(terminal_psi::StructuralContentProjection {
identity: ContentProjectionIdentity {
domain: ContentDomainId::new(owner.semantic_domain.get()).unwrap(),
projection_report_fingerprint: value.report_fingerprint(&algebra),
},
algebra,
expression: value,
});
let domains = [owner];
let defaults = DefaultRequirements::new(&types, &domains, &machine).unwrap();
let root = PlaceId::new(2).unwrap();
let mut lost = Vec::new();
defaults
.append_lost(&mut lost, root, &[], root, &[])
.unwrap();
assert!(lost.is_empty(), "{lost:?}");
let element = [StructuralPathSegment::FixedIndex(0)];
let error = defaults
.append_lost(&mut lost, root, &element, root, &[])
.unwrap_err();
assert_eq!(
error.detail,
"a named default has no complete storage predicate theory"
);
}

#[test]
fn named_defaults_are_rerooted_goals_not_membership_truth() {
let mut types = types(2);
Expand Down Expand Up @@ -333,7 +382,9 @@ fn a_window_requires_coordinates_only_for_its_potential_owners() {
types[0].requires.clear();

let owner = domain(types[1].id);
machine.structural_parameters[0].qualifications.push(owner.id);
machine.structural_parameters[0]
.qualifications
.push(owner.id);
assert!(!handback(&types, &machine, &selected, element));
assert!(!project(&types, &[owner], &machine));
}
Expand Down
Loading