Open justplaz opened 2 months ago
Thanks @justplaz!
More background from offline discussion: this is an issue because the Dafny code generation always creates its own Error
datatype for all possible errors from all operations in a service, even though there is typically no shape in the Smithy model named "Error". Other Smithy code generators tend to qualify such types with names like SomeOperationError
and/or placing them in separate namespaces, so they don't conflict with types generated from names that ARE in the Smithy model.
In this case I'd suggest changing the Dafny code generation to call the datatype <ServiceName>Error
instead, as a relatively small change to make this collision far less likely, if still not impossible. Moving Error
to a separate module would avoid all possible collisions but is likely too much disruption to be worth it right now.
Alternatively, we could treat Error
as if it was a reserved word in Dafny and escape "Error" if it appears in a model. That has to be done for legit reserved words in each language anyway, so we have to be able to handle generated symbols sometimes being different from what's in the model in documentation etc.
I am working on adding S3 to the
aws-sdk
TestModels. My WIP code is here: https://github.com/smithy-lang/smithy-dafny/pull/349The
polymorph_dafny
andpolymorph_net
commands succeed. When runningtranspile_dotnet
, I get the error below:Based on some offline discussion, this is happening because the S3 smithy-model contains a shape named Error, which clashes with smithy-dafny's Error datatype.
Excerpt from model:
The Error shape is used as part of the Errors list, which is used in batch API operations, where the operation always succeeds and success/failure is detailed for each batch item in the response object.
It is unclear whether other service models also contain an "Error" shape or not.