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

Map of embeds containing array produces invalid go code #31

Closed
radomsak opened this issue Oct 18, 2019 · 1 comment · Fixed by #36
Closed

Map of embeds containing array produces invalid go code #31

radomsak opened this issue Oct 18, 2019 · 1 comment · Fixed by #36

Comments

@radomsak
Copy link
Contributor

The following schema produces invalid go code:

{
  "name": "Pipeline",
  "description": "defines an address book.",
  "cpp": {
    "namespace": "book::address",
    "path_as": "boost::filesystem::path",
    "optional_as": "std::experimental::optional",
    "datetime_library": "ctime"
  },
  "go": {
    "package": "address"
  },
  "py": {
    "module_name": "book.address",
    "path_as": "pathlib.Path",
    "timezone_as": "pytz.timezone"
  },
  "classes": [
    {
      "name": "Person",
      "description": "defines a contactable person.",
      "properties": {
        "friends": {
          "type": "map",
          "description": "friends of a person.",
          "values": {
            "type": "Friend"
          }
        }
      }
    }
  ],
  "embeds": [
    {
      "name": "Friend",
      "description": "represents a friend.",
      "properties": {
        "personality": {
          "type": "array",
          "description": "describes a personality.",
          "values": {
            "type": "string"
          }
        }
      }
    }
  ],
  "properties": {}
}

in from_jsonable.go:

...
			target1 := make(map[string]Friend)
			for k1 := range cast1 {
				FriendFromJSONable(
					cast1[k1],
					strings.Join(
						[]string{
							ref, "friends", k1},
						"/"),
					&(target1[k1]),  // Cannot take the address of 'target1[k1]'
					errors)

				if errors.Full() {
					break;
				}
			}
...

As discussed in this golang issue it is not allowed to take an address of an element of a map.

@mristin Any help would be appreciated!

Thanks

@mristin
Copy link
Collaborator

mristin commented Oct 18, 2019

@radomsak thanks a ton for uncovering this one! It also implies that the live test covering the compilation is not failing as expected.

I'm away from a computer till Tuesday. I'll try to fix the issue Tue morning.

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

Successfully merging a pull request may close this issue.

2 participants