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
6 changes: 3 additions & 3 deletions dag/std/behavioral.dag
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module std.behavioral

type SideEffects = ReadOnly | WritesState | WritesExternal
import std.determinism { DeterminismAxis }

type Determinism = Deterministic | NonDeterministic | EventuallyConsistent
type SideEffects = ReadOnly | WritesState | WritesExternal

type Severity = Low | Medium | High | Critical

Expand Down Expand Up @@ -41,7 +41,7 @@ type CapabilityFailureContract {

type OperationBehavior {
side_effects: SideEffects
determinism: Determinism
determinism: DeterminismAxis
failure_modes: List<FailureMode>
edge_cases: List<EdgeCase>
confidence: Confidence
Expand Down
20 changes: 10 additions & 10 deletions src/v1/05_emit_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -1586,8 +1586,8 @@ fn is_type_constant(summary: TypeSummary, recursive_type_set: Set<String>) -> Bo
StructRepr =>
if is_recursive || has_generics || summary.has_fn_fields { false }
else {
let field_count = map_keys(summary.field_summaries) |> count
let ft_count = map_keys(summary.field_type_map) |> count
let field_count = sorted_map_keys(summary.field_summaries) |> count
let ft_count = sorted_map_keys(summary.field_type_map) |> count
if ft_count < field_count { false }
else { map_values(summary.field_type_map) |> all(tn => is_dag_value_type_name(name: tn)) }
}
Expand All @@ -1613,7 +1613,7 @@ fn build_shared_types(type_summaries: Map<String, TypeSummary>, recursive_type_s
maybe_mark_shared_type(acc: acc, summary: summary, recursive_type_set: recursive_type_set, target_needs_sharing: sharing.needs_sharing)
)

let collection_keys = map_keys(rust_container_templates)
let collection_keys = sorted_map_keys(rust_container_templates)
|> filter(k => sharing.needs_sharing && k != "optional" && k != "boolean_algebra")
collection_keys |> fold(init: user_shared, f: (acc, key) =>
let pascal = to_pascal(name: key)
Expand Down Expand Up @@ -2130,7 +2130,7 @@ fn import_module_enum_scope(import_module: String, registry: Map<String, ItemInf
let physical = enum_names_in_module(module_name: import_module, typed_modules: typed_modules, source_indices: source_indices, type_summaries: type_summaries, module_index: module_index)
let reexport_parents = match map_get(export_sets, import_module) {
Present { value: exported } =>
map_keys(exported) |> sort_by(k => k) |> filter(n =>
sorted_map_keys(exported) |> filter(n =>
is_known_variant(type_summaries: type_summaries, name: n)
&& is_enum_in_summaries(type_summaries: type_summaries, type_name: n) == false
) |> map(n =>
Expand Down Expand Up @@ -2187,7 +2187,7 @@ fn wildcard_import_pool_surface_names(module_name: String, visited: List<String>
|> flat_map(imp =>
let src_mod = authored_name_at(source_indices: source_indices, node: imp)
let direct = match map_get(export_sets, src_mod) {
Present { value: exported } => map_keys(exported) |> sort_by(k => k)
Present { value: exported } => sorted_map_keys(exported)
Absent => []
}
concat(
Expand All @@ -2207,7 +2207,7 @@ fn wildcard_import_pool_surface_names(module_name: String, visited: List<String>

fn wildcard_reexport_surface_names(import_module: String, export_sets: Map<String, Map<String, Bool>>, typed_modules: List<TypedModule>, source_indices: Map<String, NewlineIndex>, module_index: ModuleIndex) -> List<String> {
let local_candidates = match map_get(export_sets, import_module) {
Present { value: exported } => map_keys(exported) |> sort_by(k => k)
Present { value: exported } => sorted_map_keys(exported)
Absent => []
}
let wildcard_pool_candidates = wildcard_import_pool_surface_names(
Expand Down Expand Up @@ -4203,7 +4203,7 @@ fn pattern_parent_enum(name: String, parent_enum: String?, scrut_type: String, t
}

fn unique_variant_parent(type_summaries: Map<String, TypeSummary>, variant_name: String) -> String? {
let parent_matches = map_keys(type_summaries)
let parent_matches = sorted_map_keys(type_summaries)
|> filter(type_name =>
is_enum_type_name(type_name: type_name, type_summaries: type_summaries) &&
variant_belongs_to_enum(type_summaries: type_summaries, variant_name: variant_name, enum_name: type_name)
Expand Down Expand Up @@ -6554,7 +6554,7 @@ fn struct_candidates_by_field_names(field_names: List<String>, type_summaries: M
map_values(type_summaries) |> filter(summary =>
match summary.repr {
StructRepr =>
let ftm_keys = map_keys(summary.field_type_map)
let ftm_keys = sorted_map_keys(summary.field_type_map)
if ftm_keys |> count == n_fields {
field_names |> all(fn_name => map_contains_key(summary.field_type_map, fn_name))
} else { false }
Expand All @@ -6572,7 +6572,7 @@ fn find_struct_name_by_fields(field_names: List<String>, field_type_hints: Map<S
}
} else {
let typed_candidates = candidates |> filter(cand =>
map_keys(field_type_hints) |> all(fname =>
sorted_map_keys(field_type_hints) |> all(fname =>
match map_get(field_type_hints, fname) {
Present { value: hint_type } =>
match map_get(cand.field_type_map, fname) {
Expand Down Expand Up @@ -6781,7 +6781,7 @@ fn emit_typed_record_lit(type_name: String?, fields: List<Node>, parent_enum: St
Present { value: s } =>
let fs = s.field_summaries
let ftm = s.field_type_map
let missing = map_keys(fs) |> filter(k => !emit_map_has(m: provided_set, key: k))
let missing = sorted_map_keys(fs) |> filter(k => !emit_map_has(m: provided_set, key: k))
let all_defaultable = missing |> all(fname =>
let has_zv = match map_get(ftm, fname) {
Present { value: ft } => match rust_zero_value(type_name: ft, corpus_repr: emit_info.corpus_repr) { Present { value: _ } => true, Absent => false }
Expand Down
73 changes: 22 additions & 51 deletions src/v1/stage0/src/v1_compiler_emit_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3376,11 +3376,13 @@ pub fn is_type_constant(
false
} else {
{
let field_count =
(Rc::new(v1_rt::map_keys(&summary.field_summaries.clone())).len()
let field_count = (Rc::new(v1_rt::sorted_map_keys(
&summary.field_summaries.clone(),
))
.len() as i64);
let ft_count =
(Rc::new(v1_rt::sorted_map_keys(&summary.field_type_map.clone())).len()
as i64);
let ft_count = (Rc::new(v1_rt::map_keys(&summary.field_type_map.clone()))
.len() as i64);
if (ft_count.clone() < field_count.clone()) {
false
} else {
Expand Down Expand Up @@ -3453,7 +3455,7 @@ pub fn build_shared_types(
);
let collection_keys = Rc::new({
let mut __result = Vec::new();
for k in Rc::new(v1_rt::map_keys(&rust_container_templates()))
for k in Rc::new(v1_rt::sorted_map_keys(&rust_container_templates()))
.iter()
.cloned()
{
Expand Down Expand Up @@ -4963,21 +4965,7 @@ pub fn import_module_enum_scope(
let mut __result = Vec::new();
for n in Rc::new({
let mut __result = Vec::new();
for n in Rc::new({
let mut __sorted: Vec<_> = Rc::new(v1_rt::map_keys(&exported))
.iter()
.cloned()
.collect();
__sorted.sort_by(|a: &String, b: &String| {
let __ka = (|k: String| k.clone())(a.clone());
let __kb = (|k: String| k.clone())(b.clone());
__ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal)
});
__sorted
})
.iter()
.cloned()
{
for n in Rc::new(v1_rt::sorted_map_keys(&exported)).iter().cloned() {
if (is_known_variant(type_summaries.clone(), n.clone())
&& (is_enum_in_summaries(type_summaries.clone(), n.clone())
== false))
Expand Down Expand Up @@ -5145,20 +5133,7 @@ pub fn wildcard_import_pool_surface_names(
(*{
let src_mod = authored_name_at(source_indices.clone(), imp.clone());
let direct = match v1_rt::map_get(&export_sets, src_mod.clone()) {
Some(exported) => Rc::new({
let mut __sorted: Vec<_> =
Rc::new(v1_rt::map_keys(&exported))
.iter()
.cloned()
.collect();
__sorted.sort_by(|a: &String, b: &String| {
let __ka = (|k: String| k.clone())(a.clone());
let __kb = (|k: String| k.clone())(b.clone());
__ka.partial_cmp(&__kb)
.unwrap_or(std::cmp::Ordering::Equal)
});
__sorted
}),
Some(exported) => Rc::new(v1_rt::sorted_map_keys(&exported)),
None => Rc::new(vec![]),
};
v1_rt::concat(
Expand Down Expand Up @@ -5196,18 +5171,7 @@ pub fn wildcard_reexport_surface_names(
) -> Rc<Vec<String>> {
{
let local_candidates = match v1_rt::map_get(&export_sets, import_module.clone()) {
Some(exported) => Rc::new({
let mut __sorted: Vec<_> = Rc::new(v1_rt::map_keys(&exported))
.iter()
.cloned()
.collect();
__sorted.sort_by(|a: &String, b: &String| {
let __ka = (|k: String| k.clone())(a.clone());
let __kb = (|k: String| k.clone())(b.clone());
__ka.partial_cmp(&__kb).unwrap_or(std::cmp::Ordering::Equal)
});
__sorted
}),
Some(exported) => Rc::new(v1_rt::sorted_map_keys(&exported)),
None => Rc::new(vec![]),
};
let wildcard_pool_candidates = wildcard_import_pool_surface_names(
Expand Down Expand Up @@ -11097,7 +11061,10 @@ pub fn unique_variant_parent(
{
let parent_matches = Rc::new({
let mut __result = Vec::new();
for type_name in Rc::new(v1_rt::map_keys(&type_summaries)).iter().cloned() {
for type_name in Rc::new(v1_rt::sorted_map_keys(&type_summaries))
.iter()
.cloned()
{
if (is_enum_type_name(type_name.clone(), type_summaries.clone())
&& variant_belongs_to_enum(
type_summaries.clone(),
Expand Down Expand Up @@ -18409,7 +18376,8 @@ pub fn struct_candidates_by_field_names(
for summary in Rc::new(v1_rt::map_values(&type_summaries)).iter().cloned() {
if match (*summary.repr.clone()).clone() {
TypeRepr::StructRepr => {
let ftm_keys = Rc::new(v1_rt::map_keys(&summary.field_type_map.clone()));
let ftm_keys =
Rc::new(v1_rt::sorted_map_keys(&summary.field_type_map.clone()));
if ((ftm_keys.clone().len() as i64) == n_fields.clone()) {
{
let mut __all = true;
Expand Down Expand Up @@ -18458,7 +18426,9 @@ pub fn find_struct_name_by_fields(
for cand in candidates.clone().iter().cloned() {
if {
let mut __all = true;
for fname in Rc::new(v1_rt::map_keys(&field_type_hints)).iter().cloned()
for fname in Rc::new(v1_rt::sorted_map_keys(&field_type_hints))
.iter()
.cloned()
{
if !(match v1_rt::map_get(&field_type_hints, fname.clone()) {
Some(hint_type) => match v1_rt::map_get(
Expand Down Expand Up @@ -19144,8 +19114,9 @@ pub fn emit_typed_record_lit(
let ftm = s.field_type_map.clone();
let missing = Rc::new({
let mut __result = Vec::new();
for k in
Rc::new(v1_rt::map_keys(&fs)).iter().cloned()
for k in Rc::new(v1_rt::sorted_map_keys(&fs))
.iter()
.cloned()
{
if !emit_map_has(
provided_set.clone(),
Expand Down
Loading