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

The name of a variable or field cannot be "type" #83

Closed
elliotchance opened this issue May 6, 2017 · 4 comments
Closed

The name of a variable or field cannot be "type" #83

elliotchance opened this issue May 6, 2017 · 4 comments

Comments

@elliotchance
Copy link
Owner

type is a reserved word in Go so we not only have to replace it at the source of the declaration but also any time a variable or struct field is referenced.

@pravj
Copy link
Contributor

pravj commented May 27, 2017

The same goes for other keywords of Go those are absent in C. We should check for these names and replace them.

Can confirm failing test cases when I replace n with these names in prime.c.

@pravj
Copy link
Contributor

pravj commented May 27, 2017

SetKeywords(Go) - SetKeywords(C)

  • chan
  • defer
  • fallthrough
  • func
  • go
  • import
  • interface
  • map
  • package
  • range
  • select
  • type
  • var

Instead of checking for each such name, we can keep a map (map[string][bool]) of these names to verify if we should replace the field name.

@elliotchance
Copy link
Owner Author

I agree for a more generic solution and also that the hack that currently exists is not a valid solution.

I like the solution you suggested, would you be interested in putting in a PR for this?

@pravj
Copy link
Contributor

pravj commented May 27, 2017

Sure! I will implement it tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants