[
https://issues.apache.org/jira/browse/THRIFT-4497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16363499#comment-16363499
]
ASF GitHub Bot commented on THRIFT-4497:
----------------------------------------
GitHub user dhull opened a pull request:
https://github.com/apache/thrift/pull/1495
THRIFT-4497: Use map() field type for Erlang type for map struct fields
The Thrift Erlang code generator previously generated fields with the `#{}`
Erlang type for maps fields. In the Erlang type specification languages,
however, `#{}` specifically means an empty map. This commit fixes the code to
emit `map()` instead, which means the maps keys and values may be of any type.
It would be possible to emit a field type such as `${keytype() =>
maptype()}`, but this commit does not do that.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dhull/thrift thrift-4497-erlang-maps
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/1495.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1495
----
commit 67f7f6343f71da75b8f2257a8bb63d2ebd48dc82
Author: David Hull <david.hull@...>
Date: 2018-02-14T03:41:35Z
THRIFT-4497: Use `map()` field type for Erlang type for map struct fields.
The Thrift Erlang code generator previously generated fields with the
`#{}` Erlang type for maps fields. In the Erlang type specification
languages, however, `#{}` specifically means an empty map. This commit
fixes the code to emit `map()` instead, which means the maps keys and
values may be of any type.
It would be possible to emit a field type such as
`${keytype() => maptype()}`, but this commit does not do that.
----
> Erlang records should use map() for map type
> --------------------------------------------
>
> Key: THRIFT-4497
> URL: https://issues.apache.org/jira/browse/THRIFT-4497
> Project: Thrift
> Issue Type: Bug
> Components: Erlang - Compiler
> Affects Versions: 0.11.0
> Reporter: David Hull
> Assignee: David Hull
> Priority: Major
>
> When the Thrift Erlang code generator is given the "maps" option, it
> generates records with #{} as the field type. However #{} is the type for an
> empty map. The Erlang [Types and Function
> Specifications|http://erlang.org/doc/reference_manual/typespec.html#id79546]
> says:
> {quote}
> Notice that the syntactic representation of {{map()}} is {{#\{any() =>
> any()\}}} (or {{#\{_ => _\}}}), not #\{ \}. The notation #\{ \} specifies the
> singleton type for the empty map.
> {quote}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)