Skip to content

Commit

Permalink
fix(frontend/table_id): make Node and NodeRepr use the same field…
Browse files Browse the repository at this point in the history
… names

Not doing so breaks the JsonSchema
  • Loading branch information
W95Psp committed Nov 13, 2024
1 parent 9c0cba0 commit 0d8461e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion engine/names/extract/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod id_table {
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Node<T> {
value: Arc<T>,
cache_id: u32,
id: u32,
}

impl<T> std::ops::Deref for Node<T> {
Expand Down
4 changes: 2 additions & 2 deletions engine/utils/ocaml_of_json_schema/ocaml_of_json_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,11 @@ let parse_table_id_node (type t) (name: string) (encode: t -> map_types) (decode
let label = "parse_table_id_node:" ^ name ^ ": " in
match o with
| \`Assoc alist -> begin
let id = match List.assoc_opt "cache_id" alist with
let id = match List.assoc_opt "id" alist with
| Some (\`Int id) -> Base.Int.to_int64 id
| Some (\`Intlit lit) -> (try Base.Int64.of_string lit with | _ -> failwith (label ^ "Base.Int64.of_string failed for " ^ lit))
| Some bad_json -> failwith (label ^ "id was expected to be an int, got: " ^ Yojson.Safe.pretty_to_string bad_json ^ "\n\n\nfull json: " ^ Yojson.Safe.pretty_to_string o)
| None -> failwith (label ^ " could not find the key 'cache_id' in the following json: " ^ Yojson.Safe.pretty_to_string o)
| None -> failwith (label ^ " could not find the key 'id' in the following json: " ^ Yojson.Safe.pretty_to_string o)
in
let decode v = decode v |> Base.Option.value_exn ~message:(label ^ "could not decode value (wrong type)") in
match List.assoc_opt "value" alist with
Expand Down
8 changes: 4 additions & 4 deletions frontend/exporter/src/id_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ mod serde_repr {

#[derive(Serialize, Deserialize, JsonSchema, Debug)]
pub(super) struct NodeRepr<T> {
cache_id: Id,
id: Id,
value: Option<Arc<T>>,
}

Expand All @@ -290,8 +290,8 @@ mod serde_repr {
} else {
Some(self.value.clone())
};
let cache_id = self.id;
NodeRepr { value, cache_id }
let id = self.id;
NodeRepr { value, id }
}
}

Expand All @@ -301,7 +301,7 @@ mod serde_repr {
fn try_from(cached: NodeRepr<T>) -> Result<Self, Self::Error> {
use serde::de::Error;
let table = DESERIALIZATION_STATE.lock().unwrap();
let id = cached.cache_id;
let id = cached.id;
let kind = if let Some(kind) = cached.value {
kind
} else {
Expand Down

0 comments on commit 0d8461e

Please sign in to comment.