From dev-return-53875-archive-asf-public=cust-asf.ponee.io@thrift.apache.org Thu Nov 29 17:49:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 48FB9180789 for ; Thu, 29 Nov 2018 17:49:05 +0100 (CET) Received: (qmail 93406 invoked by uid 500); 29 Nov 2018 16:49:04 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 93382 invoked by uid 99); 29 Nov 2018 16:49:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Nov 2018 16:49:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 9105118089C for ; Thu, 29 Nov 2018 16:49:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 1wWw4jOkayjP for ; Thu, 29 Nov 2018 16:49:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 3216960EB9 for ; Thu, 29 Nov 2018 16:49:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6FA18E1328 for ; Thu, 29 Nov 2018 16:49:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 3244124DD5 for ; Thu, 29 Nov 2018 16:49:00 +0000 (UTC) Date: Thu, 29 Nov 2018 16:49:00 +0000 (UTC) From: =?utf-8?Q?Bu=C4=9Fra_Gedik_=28JIRA=29?= To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (THRIFT-4675) JS code generators not handling int64 type properly for constants and for TypeScript type mappings MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/THRIFT-4675?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D167= 03481#comment-16703481 ]=20 Bu=C4=9Fra Gedik edited comment on THRIFT-4675 at 11/29/18 4:48 PM: --------------------------------------------------------------- [~jking3] Could you please advise in two areas: * Do you agree that this should be fixed? If you agree, we are willing to= work on this and submit a patch (hopefully for the next repease). =20 * Do you think this requires an option or should it be the default behavi= or? I happen to think that it should be the default behavior, as it is a co= rrectness problem.=20 was (Author: bgedik): [~jking3] Could you please advise in two areas: * Do you agree that this should be fixed. If you agree, we are willing to= submit a patch =20 * Do you think this requires an option or should it be the default behavi= or. I happen to think that it should be the default behavior, as it is a co= rrectness problem.=20 > JS code generators not handling int64 type properly for constants and for= TypeScript type mappings > -------------------------------------------------------------------------= ------------------------- > > Key: THRIFT-4675 > URL: https://issues.apache.org/jira/browse/THRIFT-4675 > Project: Thrift > Issue Type: Bug > Components: JavaScript - Compiler > Affects Versions: 0.11.0 > Reporter: Bu=C4=9Fra Gedik > Priority: Major > > The code generated for JS constants involving the {{int64}} Thrift type d= o not rely on the {{Int64}} JS type (from the {{node-int64}} package Thrift= uses for handling 64-bit integers).=20 > For example, consider the following Thrift constant definitions: > {code} > const i64 MAX_INT64 =3D 9223372036854775807 > const i64 SMALL_INT64 =3D 15 > {code} > This results in generating the following code: > For node.js: > {code} > ttypes.MAX_INT64 =3D 9223372036854775807; =20 > ttypes.SMALL_INT64 =3D 15; =20 > {code} > For the browser: > {code} > MAX_INT64 =3D 9223372036854775807; > SMALL_INT64 =3D 15; =20 > {code} > Since the JS {{number}} type cannot natively represent integers that do n= ot fit into a double precision floating point, this will result in lost pre= cision for certain values. E.g., printing {{MAX_INT64}} would produce {{922= 337203685477}}*{{6000}}*.=20 > The correct output should be (showing for node.js): > {code} > ttypes.MAX_INT64 =3D new Int64(''7FFFFFFFFFFFFFFF''); =20 > ttypes.SMALL_INT64 =3D new Int64(15); =20 > {code} > Besides this, none of the Typescript type bindings ({{.d.ts}} files) cont= ain the types for int64 types. This includes constants, types, and service = method parameters.=20 > Note that fixing this may break some of the existing code. In my mind, th= is is how it should work by default, but I don't know the policy in Thrift = regarding backward compatibility. It could also be added as an option. -- This message was sent by Atlassian JIRA (v7.6.3#76005)