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

go: parameters named "_" result in invalid code #2530

Closed
1 of 5 tasks
eladb opened this issue Feb 4, 2021 · 1 comment
Closed
1 of 5 tasks

go: parameters named "_" result in invalid code #2530

eladb opened this issue Feb 4, 2021 · 1 comment
Assignees
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@eladb
Copy link
Contributor

eladb commented Feb 4, 2021

🐛 Bug Report

Affected Languages

  • Golang
  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

General Information

  • JSII Version: 1.20.0
  • Platform: all

What is the problem?

It is a common practice in jsii/TypeScript to use _ as a parameter name if the parameter is not used in a method implementation:

public foo(hello: string, _: number) {
  console.log(hello);
}

The resulting go code does not compile:

cannot use _ as value
@eladb eladb added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 4, 2021
eladb pushed a commit to cdk8s-team/cdk8s that referenced this issue Feb 4, 2021
eladb pushed a commit to cdk8s-team/cdk8s that referenced this issue Feb 4, 2021
Build & publishes experimental Go bindings for CDK8s under `github.com/awslabs/cdk8s-go/cdk8s` and `github.com/awslabs/cdk8s-go/cdk8splus17`.

This required the following changes:
- Add `publishToGo` definitions to `cdk8s` and `cdk8s-plus-17`
- Upgrading constructs to 3.3.5 (which is available in go)
- Remove the use of `_` as a parameter name due to aws/jsii#2530



Resolves aws/jsii#2444
Resolves aws/jsii#2454
@MrArnoldPalmer MrArnoldPalmer added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Feb 16, 2021
@eladb eladb assigned eladb and unassigned MrArnoldPalmer Mar 15, 2021
eladb pushed a commit that referenced this issue Mar 15, 2021
It is common in TypeScript to use `_` as an argument name if the argument is not used. This is an invalid name in Go, so replace it with `_arg`.

Fixes #2530
@eladb eladb changed the title Golang: parameters named "_" result in invalid code go: parameters named "_" result in invalid code Mar 15, 2021
@eladb eladb closed this as completed Mar 18, 2021
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants