Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writables string interpolation does not work with camelcase identifiers #1459

Closed
crisidev opened this issue Jun 13, 2022 · 1 comment · Fixed by #1467
Closed

Writables string interpolation does not work with camelcase identifiers #1459

crisidev opened this issue Jun 13, 2022 · 1 comment · Fixed by #1467
Labels
bug Something isn't working

Comments

@crisidev
Copy link
Contributor

Let's say we have a writable like this one:

fun renderObject(): Writable =
    writable {
        rust("""let mystring = String::from("Weeeeeeeee");""");
    }

The writable can be interpolated in any rustTemplate like this:

rustTemplate("#{myobject:W}", "myobject" to renderObject())

If I setup the context using a camelcase identifier (IE myObject instead of myobject), it results in a Kotlin stacktrace:

Projection pokemon_service_sdk failed: java.lang.NullPointerException: Parameter specified as non-null is null: method software.amazon.smithy.rust.codegen.rustlang.RustWriter$RustWriteableInjector.apply, parameter t
software.amazon.smithy.rust.codegen.rustlang.RustWriter$RustWriteableInjector.apply(RustWriter.kt)
software.amazon.smithy.rust.codegen.rustlang.RustWriter$RustWriteableInjector.apply(RustWriter.kt:516)
software.amazon.smithy.utils.AbstractCodeWriter.applyFormatter(AbstractCodeWriter.java:1861)
software.amazon.smithy.utils.CodeFormatter$Operation.lambda$formatted$1(CodeFormatter.java:108)
software.amazon.smithy.utils.CodeFormatter$BlockOperation$Unconditional.apply(CodeFormatter.java:228)
software.amazon.smithy.utils.CodeFormatter.run(CodeFormatter.java:41)
software.amazon.smithy.utils.AbstractCodeWriter.format(AbstractCodeWriter.java:1596)
software.amazon.smithy.utils.AbstractCodeWriter.write(AbstractCodeWriter.java:1652)
software.amazon.smithy.rust.codegen.rustlang.RustWriter.write(RustWriter.kt:363)
software.amazon.smithy.rust.codegen.rustlang.RustWriterKt$rustTemplate$1.invoke(RustWriter.kt:189)
software.amazon.smithy.rust.codegen.rustlang.RustWriterKt$rustTemplate$1.invoke(RustWriter.kt:188)
software.amazon.smithy.rust.codegen.rustlang.RustWriterKt.withTemplate(RustWriter.kt:91)
software.amazon.smithy.rust.codegen.rustlang.RustWriterKt.rustTemplate(RustWriter.kt:188)
software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerEnumGenerator.renderPyO3Methods(PythonServerEnumGenerator.kt:56)
software.amazon.smithy.rust.codegen.server.python.smithy.generators.PythonServerEnumGenerator.render(PythonServerEnumGenerator.kt:46)
software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCodegenVisitor$stringShape$1$1.invoke(PythonServerCodegenVisitor.kt:163)
software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCodegenVisitor$stringShape$1$1.invoke(PythonServerCodegenVisitor.kt:162)
software.amazon.smithy.rust.codegen.smithy.RustCrate.useShapeWriter$lambda-0(CodegenDelegator.kt:60)
software.amazon.smithy.codegen.core.WriterDelegator.useShapeWriter(WriterDelegator.java:208)
software.amazon.smithy.rust.codegen.smithy.RustCrate.useShapeWriter(CodegenDelegator.kt:60)
software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCodegenVisitor.stringShape(PythonServerCodegenVisitor.kt:162)
software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCodegenVisitor.stringShape(PythonServerCodegenVisitor.kt:42)
software.amazon.smithy.model.shapes.StringShape.accept(StringShape.java:41)
software.amazon.smithy.rust.codegen.server.python.smithy.PythonServerCodegenVisitor.execute(PythonServerCodegenVisitor.kt:105)
software.amazon.smithy.rust.codegen.server.python.smithy.PythonCodegenServerPlugin.execute(PythonCodegenServerPlugin.kt:47)
software.amazon.smithy.build.SmithyBuildImpl.applyPlugin(SmithyBuildImpl.java:397)
software.amazon.smithy.build.SmithyBuildImpl.applyProjection(SmithyBuildImpl.java:328)
software.amazon.smithy.build.SmithyBuildImpl.executeSerialProjection(SmithyBuildImpl.java:224)
software.amazon.smithy.build.SmithyBuildImpl.lambda$applyAllProjections$5(SmithyBuildImpl.java:189)
java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1448)
java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
@82marbag
Copy link
Contributor

Had reported to @rcoh - there should be a fix being worked on?

rcoh added a commit that referenced this issue Jun 15, 2022
rcoh added a commit that referenced this issue Jun 15, 2022
rcoh added a commit that referenced this issue Jun 15, 2022
Velfi pushed a commit that referenced this issue Jun 15, 2022
* Fixes for RustWriter bugs #1465 & #1459

* Fix behavior causing extra newlines in docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants