Implement a wrapper type for AST nodes.

This is to make it impossible to have a collision for attribute names that are real attributes vs attributes I've added for structure (like children and ast_node).
This commit is contained in:
Tom Alexander
2023-12-29 11:56:28 -05:00
parent 77e0dbb42e
commit 9f4f8e79ce
3 changed files with 47 additions and 3 deletions

View File

@@ -87,7 +87,7 @@ fn compare_json_value<'b, 's>(
emacs: &'b Token<'s>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
match (value, emacs) {
(serde_json::Value::Object(wasm), Token::List(el)) if wasm.contains_key("__ast_node") => {
(serde_json::Value::Object(wasm), Token::List(el)) if wasm.contains_key("ast_node") => {
// We hit a regular ast node.
compare_ast_node(source, el, wasm)
}
@@ -133,7 +133,7 @@ fn compare_ast_node<'b, 's, 'p>(
.ok_or("Should have a name as the first child.")?
.as_atom()?;
let wasm_name = wasm
.get("__ast_node")
.get("ast_node")
.ok_or("Should have a ast node type.")?
.as_str()
.ok_or("Ast node type should be a string.")?;