From be57de1bffc68df00deccb65180f3b8ffc44b8df Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Fri, 6 Dec 2024 12:49:34 -0600 Subject: [PATCH] Do not error in comm code generator when 'name' property present in object that has enum (#5645) Addresses #2139. This isn't causing active harm, but a sharp edge that will hit comm developers with a confusing error message when an object property is called "name" and there is another property that is an enum. I tested this out with the example from the linked issue and it works correctly. I also checked that this change does not impact any of the generated comm code. --- positron/comms/generate-comms.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/positron/comms/generate-comms.ts b/positron/comms/generate-comms.ts index d66780cee4f..01c47d1e02e 100644 --- a/positron/comms/generate-comms.ts +++ b/positron/comms/generate-comms.ts @@ -314,7 +314,7 @@ function* enumVisitor( } else if (typeof contract === 'object') { // If this object is an object, recurse into each property for (const key of Object.keys(contract)) { - if (contract['name']) { + if (contract['name'] && typeof contract['name'] === 'string') { // If this is a named object, push the name onto the context // and recurse yield* enumVisitor(