MIME-Version: | 1.0 |
X-Spam-Status: | No, score=-2.214 tagged_above=-99.9 required=10 tests=[AWL=-0.303, BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=ham |
Content-Disposition: | inline |
X-Spam-Flag: | NO |
content-type: | text/plain; charset="utf-8" |
Message-ID: | <20150204125917.GA12360@fysh.org> |
X-Virus-Scanned: | Debian amavisd-new at bestpractical.com |
X-Spam-Score: | -2.214 |
Received: | from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 6F3372400E1 for <cpan-bug+Sereal-Encoder@hipster.bestpractical.com>; Wed, 4 Feb 2015 07:59:30 -0500 (EST) |
Received: | from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vSAB+NG+PL4W for <cpan-bug+Sereal-Encoder@hipster.bestpractical.com>; Wed, 4 Feb 2015 07:59:28 -0500 (EST) |
Received: | from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 7D5B02400D2 for <bug-Sereal-Encoder@rt.cpan.org>; Wed, 4 Feb 2015 07:59:28 -0500 (EST) |
Received: | (qmail 29135 invoked by alias); 4 Feb 2015 12:59:28 -0000 |
Received: | from river.fysh.org (HELO river.fysh.org) (5.135.154.127) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 04 Feb 2015 04:59:25 -0800 |
Received: | from zefram by river.fysh.org with local (Exim 4.80 #2 (Debian)) id 1YIzY5-0003Wg-6m; Wed, 04 Feb 2015 12:59:17 +0000 |
Delivered-To: | cpan-bug+Sereal-Encoder@hipster.bestpractical.com |
Subject: | bitwise behaviour not preserved |
Return-Path: | <zefram@fysh.org> |
X-RT-Mail-Extension: | sereal-encoder |
X-Original-To: | cpan-bug+Sereal-Encoder@hipster.bestpractical.com |
X-Spam-Check-BY: | la.mx.develooper.com |
Date: | Wed, 4 Feb 2015 12:59:17 +0000 |
X-Spam-Level: | |
To: | bug-Sereal-Encoder@rt.cpan.org |
From: | Zefram <zefram@fysh.org> |
X-RT-Original-Encoding: | ascii |
X-RT-Interface: | |
Content-Length: | 1338 |
$ perl -MSereal::Encoder=encode_sereal -MSereal::Decoder=decode_sereal -MTest::More=no_plan -MDevel::Peek -lwe 'sub roundtrip_ok { ok +(decode_sereal(encode_sereal($_[0])) ^ "1") eq ($_[0] ^ "1"); } roundtrip_ok 1; roundtrip_ok "1"; my $a = "1"; my $b = $a+0; my $c = $a+0.5; roundtrip_ok $a'
ok 1
ok 2
not ok 3
# Failed test at -e line 1.
1..3
# Looks like you failed 1 test of 3.
This is testing whether scalars are treated as numbers or as strings
for the purposes of bitwise ops. This is a visible feature of a scalar,
which Sereal should probably preserve. Internally the test is actually
SvNIOK(). Sereal preserves this status for most scalars, but a scalar
that is simultaneously IOK, NOK, and POK comes out POK-only, thus changing
its SvNIOK() status.
Obviously, this interacts with whatever is done for [rt.cpan.org #101876].
Simple fixes for that cause the bitwise-roundtrip test to fail in more
cases. Preserving bitwise status while also preserving string value
would require essentially passing at least one NIOK bit alongside a
string value, which would require a protocol addition. If the protocol
is going to be changed in this area, it might be wise to extend it to
full dualvar handling at the same time.
If you'd rather not have Sereal preserve bitwise status, this limitation
should be documented.
-zefram