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
When using withIndent in an expression function, the emitted code does not unindent properly. Automatic wrapping then causes compilation to fail as deeply nested code gets squeezed against the margin.
To reproduce, run ./gradlew protokt-core-lite:build. The issue manifests in the generated code file descriptor.kt.
Errors are like: e: /Users/.../protokt/protokt-core-lite/build/generated-sources/main/protokt/com/toasttab/protokt/descriptor.kt: (8132, 176): Expecting a top level declaration
Expected behavior
My overall goal is to generate expression functions whose bodies begin on the next line, like so:
funfoo() ="some very long expression "+"that stretches on for many lines"
And the source of this bug is in MessageGenerator.kt:
Describe the bug
When using
withIndent
in an expression function, the emitted code does not unindent properly. Automatic wrapping then causes compilation to fail as deeply nested code gets squeezed against the margin.To Reproduce
Unfortunately I don't have a simple example, but I do have a branch that reproduces the problem: https://github.com/andrewparmet/protokt/tree/demo-broken-indentation
To reproduce, run
./gradlew protokt-core-lite:build
. The issue manifests in the generated code filedescriptor.kt
.Errors are like:
e: /Users/.../protokt/protokt-core-lite/build/generated-sources/main/protokt/com/toasttab/protokt/descriptor.kt: (8132, 176): Expecting a top level declaration
Expected behavior
My overall goal is to generate expression functions whose bodies begin on the next line, like so:
And the source of this bug is in
MessageGenerator.kt
:If I remove
withIndent()
then the code generates ok, although it's not pretty.Thanks!
Additional Context
Note that the code generator has a formatting pass that is disabled; it is found in
GeneratedCodeCleanup.kt
.The text was updated successfully, but these errors were encountered: