Skip to content

Commit bdf0b4e

Browse files
fix(ruby): prevent duplicate errors in undiscriminated union conversion
Return the already-converted result from the cloned context instead of calling convert() again on the main context. This prevents duplicate errors when the same conversion is performed twice. Co-Authored-By: [email protected] <[email protected]>
1 parent c8cd99d commit bdf0b4e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

generators/ruby-v2/dynamic-snippets/src/context/DynamicToLiteralMapper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,10 @@ export class DynamicTypeLiteralMapper {
342342
const clonedContext = this.context.clone();
343343
const clonedMapper = new DynamicTypeLiteralMapper({ context: clonedContext });
344344
const result = clonedMapper.convert({ typeReference, value });
345-
// If no errors were added, this type matched
345+
// If no errors were added, this type matched - return the already-converted result
346+
// to avoid duplicate errors from calling convert() again on the main context
346347
if (clonedContext.errors.empty()) {
347-
return this.convert({ typeReference, value });
348+
return result;
348349
}
349350
}
350351
this.context.errors.add({

0 commit comments

Comments
 (0)