thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James E. King, III (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (THRIFT-4495) Erlang records should allow 'undefined' for non-required fields
Date Thu, 22 Mar 2018 00:59:00 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-4495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

James E. King, III resolved THRIFT-4495.
----------------------------------------
       Resolution: Fixed
    Fix Version/s: 0.12.0

> Erlang records should allow 'undefined' for non-required fields
> ---------------------------------------------------------------
>
>                 Key: THRIFT-4495
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4495
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Erlang - Compiler
>    Affects Versions: 0.11.0
>            Reporter: David Hull
>            Assignee: David Hull
>            Priority: Major
>             Fix For: 0.12.0
>
>
> The Erlang records created by the Erlang code generator allow only the type declared
by the Thrift definition file. If a field is not required, however, the Erlang record should
also allow the value {{undefined}} (this is similar to a null value in other languages).
> Erlang includes a tool, dialyzer, that does type analysis of Erlang code. Until Erlang
19, dialyzer implicitly added `undefined` as an allowed type for all record fields, but as
of Erlang 19 it no longer does. This means that dialyzer now emits error messages whenever
a record is constructed and initial values are not specified for all of its fields.
> So, for example, the following thrift definition
> {noformat}
> struct Test {
>   1: required i32 a
>   2: i32 b
>   3: optional i32 c
> }{noformat}
> currently produced the following Erlang record:
> {noformat}
> -record('Test', {'a' :: integer(),
>                  'b' :: integer(),
>                  'c' :: integer()}).{noformat}
>  However it should produce the following:
> {noformat}
> -record('Test', {'a' :: integer(),
>                  'b' :: integer() | undefined,
>                  'c' :: integer() | undefined}).{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message