You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt
+22-8Lines changed: 22 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -370,13 +370,19 @@ class JsonSerializerGeneratorTest {
370
370
@Test
371
371
fun`union with unit struct doesn't cause unused variable warning`() {
372
372
// Regression test for https://github.com/smithy-lang/smithy-rs/issues/4308
373
+
//
374
+
// PROBLEM BEFORE FIX: JSON serializer generated `UnitMember(_inner)` but tried to use `inner`
375
+
// This caused compilation errors: "cannot find value `inner` in this scope"
376
+
//
377
+
// SOLUTION AFTER FIX: Generate `UnitMember(inner)` so variable name matches usage
378
+
// This test verifies the FIXED behavior compiles and works correctly
373
379
val model =RecursiveShapeBoxer().transform(OperationNormalizer.transform(unionWithUnitStructModel))
374
380
375
381
val codegenContext = testCodegenContext(model)
376
382
val symbolProvider = codegenContext.symbolProvider
377
383
val project =TestWorkspace.testProject(symbolProvider)
378
384
379
-
// Generate the JSON serializer that will create the union serialization code
385
+
// Generate the JSON serializer with our FIX applied
380
386
val jsonSerializer =
381
387
JsonSerializerGenerator(
382
388
codegenContext,
@@ -393,23 +399,31 @@ class JsonSerializerGeneratorTest {
Copy file name to clipboardExpand all lines: codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGeneratorTest.kt
+16-4Lines changed: 16 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,8 @@ class QuerySerializerGeneratorTest {
25
25
@Test
26
26
fun`union with unit struct doesn't cause unused variable warning`() {
27
27
// Regression test for https://github.com/smithy-lang/smithy-rs/issues/4308
28
+
//
29
+
// This test demonstrates the BEFORE/AFTER behavior for Query serialization
28
30
val model =
29
31
RecursiveShapeBoxer().transform(
30
32
OperationNormalizer.transform(
@@ -52,6 +54,8 @@ class QuerySerializerGeneratorTest {
52
54
53
55
val codegenContext = testCodegenContext(model)
54
56
val symbolProvider = codegenContext.symbolProvider
57
+
58
+
// Generate the Query serializer with our FIX applied
55
59
val parserSerializer =AwsQuerySerializerGenerator(codegenContext)
56
60
val operationGenerator = parserSerializer.operationInputSerializer(model.lookup("test#TestOp"))
57
61
@@ -65,16 +69,24 @@ class QuerySerializerGeneratorTest {
0 commit comments