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

.splice loses containerization on replacement value #6194

Open
p6rt opened this issue Apr 16, 2017 · 6 comments
Open

.splice loses containerization on replacement value #6194

p6rt opened this issue Apr 16, 2017 · 6 comments

Comments

@p6rt
Copy link

@p6rt p6rt commented Apr 16, 2017

Migrated from rt.perl.org#131162 (status was 'open')

Searchable as RT131162$

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Apr 16, 2017

From @lizmat

Actually reported as a SO question by brian d foy​:

  http://stackoverflow.com/questions/43437664/how-can-i-get-around-a-slurpy-parameter-in-the-perl-6-signature

<lizmat> m​: my @​a = [1,1],[2,2],[3,3]; dd @​a; @​a.splice​: 0, 2, $[4,4]; dd @​a # feels like a bug that the containerization of [4,4] is being ignored
<+camelia> rakudo-moar 188711​: OUTPUT​: «Array @​a = [[1, 1], [2, 2], [3, 3]]␤Array @​a = [4, 4, [3, 3]]␤»
<jnthn> lizmat​: Yeah, it's because there's a candidate with @​new at the end that it binds to, decontainerizing it in the process.
<jnthn> So it's not actually hitting the slurpy at all
<lizmat> so you agree it's wrong atm
<jnthn> The slurpy is **@​foo
<jnthn> So in fact if it *was* hitting the slurpy it would be behaving right :)
<jnthn> Yeah, it's wrong to discard the itemization
<lizmat> ok, so we are in agreement
<jnthn> I wonder if it was untested and then accidentally regressed when splice was optimized by breaking it out into a bunch of candidates
<lizmat> will file a rakudobug
<jnthn> Since I seem to recall splice getting at least something of a look during the GLR
<jnthn> And I can't imagine we settled on "it ignores itemization" :)
<jnthn> bisectable6​: my @​a = [1,1],[2,2],[3,3]; @​a.splice​: 0, 2, $[4,4]; dd @​a
<+bisectable6> jnthn, On both starting points (old=2015.12 new=1887114) the exit code is 0 and the output is identical as well
<+bisectable6> jnthn, Output on both points​: «Array @​a = [4, 4, [3, 3]]»
<jnthn> Hm, nope
<jnthn> It's been like that since Christmas
<lizmat> ok, doesn't make it right, though :-)
<jnthn> Indeed
<lizmat> but will wait for the release to look at fixing it
<jnthn> *nod*

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Sep 9, 2017

From tomentiruran@gmail.com

my @​h
[]
@​h.splice​: 0, 0, 1.Seq
[]
@​h[0].VAR.WHAT
(Int)
@​h[0] = 5
Cannot modify an immutable Int (1)
  in block <unit> at <unknown file> line 1

I got hit by this with​: @​a.splice​: 0, 0, Any xx 2


perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.
perl6 -V
distro​::auth=Apple Computer, Inc.
distro​::desc=2017-09-09T09​:21​:56.148447+08​:00
distro​::is-win=False
distro​::name=macosx
distro​::path-sep=​:
distro​::release=16G29
distro​::signature=
distro​::version=10.12.6
kernel​::arch=i386
kernel​::archname=x86_64-darwin
kernel​::auth=unknown
kernel​::bits=64
kernel​::desc=
kernel​::hardware=x86_64
kernel​::name=darwin
kernel​::release=Darwin Kernel Version 16.7.0​: Thu Jun 15 17​:36​:27 PDT 2017; root​:xnu-3789.70.16~2/RELEASE_X86_64
kernel​::signature=
kernel​::version=16.7.0
moar​::ar=ar
moar​::arflags=rcs
moar​::arout=
moar​::asm=.s
moar​::asmout=-o
moar​::asmswitch=-S
moar​::auxclean=@​​:
moar​::be=0
moar​::bindir=/Applications/Rakudo/bin
moar​::booltype=_Bool
moar​::can_unaligned_int32=1
moar​::can_unaligned_int64=1
moar​::can_unaligned_num64=1
moar​::cancgoto=1
moar​::canrdtscp=1
moar​::cat=cat
moar​::cc=clang
moar​::cc_covflags=-fprofile-instr-generate -fcoverage-mapping
moar​::ccdebugflags=-g3
moar​::ccdef=-D
moar​::ccdefflags=-D_DARWIN_USE_64_BIT_INODE=1
moar​::ccinc=-I
moar​::ccinstflags=-fsanitize=address
moar​::ccmiscflags=-fno-omit-frame-pointer -fno-optimize-sibling-calls
moar​::ccoptiflags=-O3 -DNDEBUG
moar​::ccout=-o
moar​::ccshared=
moar​::ccswitch=-c
moar​::ccwarnflags=-Wno-logical-op-parentheses
moar​::cflags=-fno-omit-frame-pointer -fno-optimize-sibling-calls -O3 -DNDEBUG -Wno-logical-op-parentheses -D_DARWIN_USE_64_BIT_INODE=1
moar​::cincludes= -I3rdparty/libuv/include -I3rdparty/libuv/src -I3rdparty/libatomic_ops/src -I3rdparty/libtommath -I3rdparty/dynasm -I3rdparty/dyncall/dynload -I3rdparty/dyncall/dyncall -I3rdparty/dyncall/dyncallback
moar​::config=--optimize --prefix=/Applications/Rakudo --make-install
moar​::cppout=>
moar​::cppswitch=-E
moar​::crossconf=
moar​::dcbclean=$(RM) 3rdparty/dyncall/dyncallback/libdyncallback_s.a
moar​::dcblib=3rdparty/dyncall/dyncallback/libdyncallback_s.a
moar​::dcbobjects=
moar​::dcbrule=@​​:
moar​::dcclean=cd 3rdparty/dyncall && $(MAKE) -f Makefile clean
moar​::dclib=3rdparty/dyncall/dyncall/libdyncall_s.a
moar​::dcobjects=
moar​::dcrule=cd 3rdparty/dyncall && ./configure && CC='$(CC)' CFLAGS='-fPIC' $(MAKE) -f Makefile
moar​::defs[0]=_DARWIN_USE_64_BIT_INODE=1
moar​::dlclean=$(RM) 3rdparty/dyncall/dynload/libdynload_s.a
moar​::dll=lib%s.dylib
moar​::dllexport=__attribute__ ((visibility ("default")))
moar​::dllib=3rdparty/dyncall/dynload/libdynload_s.a
moar​::dllimport=__attribute__ ((visibility ("default")))
moar​::dlllocal=__attribute__ ((visibility ("hidden")))
moar​::dlobjects=
moar​::dlrule=@​​:
moar​::dynasmlua=./3rdparty/dynasm/dynasm.lua
moar​::exe=
moar​::formatattribute=__attribute__((format(X, Y, Z)))
moar​::has_pthread_yield=0
moar​::havebooltype=1
moar​::impinst=libmoar.dylib
moar​::install= $(MKPATH) $(DESTDIR)$(PREFIX)/include/libuv $(CP) 3rdparty/libuv/include/*.h $(DESTDIR)$(PREFIX)/include/libuv $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/armcc $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/gcc $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/hpc $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/ibmc $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/icc $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/loadstore $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/msftc $(MKPATH) $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/sunc $(CP) 3rdparty/libatomic_ops/src/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops $(CP) 3rdparty/libatomic_ops/src/atomic_ops/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/armcc/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/armcc $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/gcc/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/gcc $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/hpc/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/hpc $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/ibmc/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/ibmc $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/icc/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/icc $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/loadstore/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/loadstore $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/msftc/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/msftc $(CP) 3rdparty/libatomic_ops/src/atomic_ops/sysdeps/sunc/*.h $(DESTDIR)$(PREFIX)/include/libatomic_ops/atomic_ops/sysdeps/sunc $(MKPATH) $(DESTDIR)$(PREFIX)/include/libtommath $(CP) 3rdparty/libtommath/*.h $(DESTDIR)$(PREFIX)/include/libtommath $(MKPATH) $(DESTDIR)$(PREFIX)/include/dyncall $(CP) 3rdparty/dyncall/dynload/*.h $(DESTDIR)$(PREFIX)/include/dyncall $(CP) 3rdparty/dyncall/dyncall/*.h $(DESTDIR)$(PREFIX)/include/dyncall $(CP) 3rdparty/dyncall/dyncallback/*.h $(DESTDIR)$(PREFIX)/include/dyncall
moar​::jit=$(JIT_POSIX_X64)
moar​::laoclean=cd 3rdparty/libatomic_ops/src && $(MAKE) distclean
moar​::laolib=3rdparty/libatomic_ops/src/libatomic_ops.a
moar​::laoobjects=
moar​::laorule=cd 3rdparty/libatomic_ops && CC='$(CC)' CFLAGS='$(CFLAGS)' ./configure && cd src && $(MAKE) && cd ..
moar​::ld=clang
moar​::ld_covflags=-fprofile-instr-generate -fcoverage-mapping
moar​::lddebugflags=-g3
moar​::lddir=-L
moar​::ldflags= -O3 -DNDEBUG -Wl,-rpath,"//Applications/Rakudo/lib"
moar​::ldimp=
moar​::ldinstflags=-fsanitize=address
moar​::ldlibs=-lpthread
moar​::ldmiscflags=
moar​::ldoptiflags=-O3 -DNDEBUG
moar​::ldout=-o
moar​::ldrpath=-Wl,-rpath,"//Applications/Rakudo/lib"
moar​::ldshared=-dynamiclib
moar​::ldsys=-l%s
moar​::ldusr=-l%s
moar​::lib=lib%s.a
moar​::libdir=/Applications/Rakudo/lib
moar​::lua=./3rdparty/dynasm/minilua
moar​::mainflags=-DMVM_SHARED
moar​::mainlibs=-L. -lmoar
moar​::make=make
moar​::mastdir=/Applications/Rakudo/share/nqp/lib/MAST
moar​::mkflags=
moar​::mknoisy=ifneq ($(NOISY), 1)MSG = @​echoCMD = @​NOOUT = > /dev/nullNOERR = 2> /dev/nullendif
moar​::moar=libmoar.dylib
moar​::moardll=libmoar.dylib
moar​::moarlib=libmoar.a
moar​::moarshared=-install_name "/Applications/Rakudo/lib/libmoar.dylib"
moar​::mtclean=$(RM) 3rdparty/tinymt/libtinymt.a 3rdparty/tinymt/*.o
moar​::mtlib=3rdparty/tinymt/libtinymt.a
moar​::mtobjects=3rdparty/tinymt/tinymt64.o
moar​::mtrule=$(AR) $(ARFLAGS) $@​ 3rdparty/tinymt/*.o
moar​::name=moar
moar​::nativecall_backend=dyncall
moar​::noreturnattribute=__attribute__((noreturn))
moar​::noreturnspecifier=
moar​::nul=/dev/null
moar​::obj=.o
moar​::objflags=-DMVM_BUILD_SHARED
moar​::os=darwin
moar​::osname=darwin
moar​::osvers=14.3.0
moar​::perl=/Users/steve/perl5/perlbrew/perls/perl-5.22.0/bin/perl
moar​::pkgconfig=/usr/bin/pkg-config
moar​::platform=$(PLATFORM_POSIX)
moar​::prefix=/Applications/Rakudo
moar​::ptr_size=8
moar​::rm=rm -f
moar​::sh=/bin/sh
moar​::shaclean=$(RM) 3rdparty/sha1/libsha1.a 3rdparty/sha1/*.o
moar​::shaincludedir=3rdparty/sha1
moar​::shalib=3rdparty/sha1/libsha1.a
moar​::shaobjects=3rdparty/sha1/sha1.o
moar​::sharedlib=libmoar.dylib
moar​::sharule=$(AR) $(ARFLAGS) $@​ 3rdparty/sha1/*.o
moar​::static_inline=static __inline__
moar​::staticlib=
moar​::thirdpartylibs=3rdparty/dyncall/dyncall/libdyncall_s.a 3rdparty/dyncall/dyncallback/libdyncallback_s.a 3rdparty/dyncall/dynload/libdynload_s.a 3rdparty/libatomic_ops/src/libatomic_ops.a 3rdparty/tinymt/libtinymt.a 3rdparty/sha1/libsha1.a 3rdparty/libtommath/libtommath.a 3rdparty/libuv/libuv.a
moar​::tomclean=$(RM) 3rdparty/libtommath/libtommath.a 3rdparty/libtommath/*.o
moar​::tomlib=3rdparty/libtommath/libtommath.a
moar​::tomobjects=3rdparty/libtommath/bn_error.o 3rdparty/libtommath/bn_fast_mp_invmod.o 3rdparty/libtommath/bn_fast_mp_montgomery_reduce.o 3rdparty/libtommath/bn_fast_s_mp_mul_digs.o 3rdparty/libtommath/bn_fast_s_mp_mul_high_digs.o 3rdparty/libtommath/bn_fast_s_mp_sqr.o 3rdparty/libtommath/bn_mp_2expt.o 3rdparty/libtommath/bn_mp_abs.o 3rdparty/libtommath/bn_mp_add.o 3rdparty/libtommath/bn_mp_add_d.o 3rdparty/libtommath/bn_mp_addmod.o 3rdparty/libtommath/bn_mp_and.o 3rdparty/libtommath/bn_mp_clamp.o 3rdparty/libtommath/bn_mp_clear.o 3rdparty/libtommath/bn_mp_clear_multi.o 3rdparty/libtommath/bn_mp_cmp.o 3rdparty/libtommath/bn_mp_cmp_d.o 3rdparty/libtommath/bn_mp_cmp_mag.o 3rdparty/libtommath/bn_mp_cnt_lsb.o 3rdparty/libtommath/bn_mp_copy.o 3rdparty/libtommath/bn_mp_count_bits.o 3rdparty/libtommath/bn_mp_div.o 3rdparty/libtommath/bn_mp_div_2.o 3rdparty/libtommath/bn_mp_div_2d.o 3rdparty/libtommath/bn_mp_div_3.o 3rdparty/libtommath/bn_mp_div_d.o 3rdparty/libtommath/bn_mp_dr_is_modulus.o 3rdparty/libtommath/bn_mp_dr_reduce.o 3rdparty/libtommath/bn_mp_dr_setup.o 3rdparty/libtommath/bn_mp_exch.o 3rdparty/libtommath/bn_mp_export.o 3rdparty/libtommath/bn_mp_expt_d.o 3rdparty/libtommath/bn_mp_expt_d_ex.o 3rdparty/libtommath/bn_mp_exptmod.o 3rdparty/libtommath/bn_mp_exptmod_fast.o 3rdparty/libtommath/bn_mp_exteuclid.o 3rdparty/libtommath/bn_mp_fread.o 3rdparty/libtommath/bn_mp_fwrite.o 3rdparty/libtommath/bn_mp_gcd.o 3rdparty/libtommath/bn_mp_get_int.o 3rdparty/libtommath/bn_mp_get_long.o 3rdparty/libtommath/bn_mp_get_long_long.o 3rdparty/libtommath/bn_mp_grow.o 3rdparty/libtommath/bn_mp_import.o 3rdparty/libtommath/bn_mp_init.o 3rdparty/libtommath/bn_mp_init_copy.o 3rdparty/libtommath/bn_mp_init_multi.o 3rdparty/libtommath/bn_mp_init_set.o 3rdparty/libtommath/bn_mp_init_set_int.o 3rdparty/libtommath/bn_mp_init_size.o 3rdparty/libtommath/bn_mp_invmod.o 3rdparty/libtommath/bn_mp_invmod_slow.o 3rdparty/libtommath/bn_mp_is_square.o 3rdparty/libtommath/bn_mp_jacobi.o 3rdparty/libtommath/bn_mp_karatsuba_mul.o 3rdparty/libtommath/bn_mp_karatsuba_sqr.o 3rdparty/libtommath/bn_mp_lcm.o 3rdparty/libtommath/bn_mp_lshd.o 3rdparty/libtommath/bn_mp_mod.o 3rdparty/libtommath/bn_mp_mod_2d.o 3rdparty/libtommath/bn_mp_mod_d.o 3rdparty/libtommath/bn_mp_montgomery_calc_normalization.o 3rdparty/libtommath/bn_mp_montgomery_reduce.o 3rdparty/libtommath/bn_mp_montgomery_setup.o 3rdparty/libtommath/bn_mp_mul.o 3rdparty/libtommath/bn_mp_mul_2.o 3rdparty/libtommath/bn_mp_mul_2d.o 3rdparty/libtommath/bn_mp_mul_d.o 3rdparty/libtommath/bn_mp_mulmod.o 3rdparty/libtommath/bn_mp_n_root.o 3rdparty/libtommath/bn_mp_n_root_ex.o 3rdparty/libtommath/bn_mp_neg.o 3rdparty/libtommath/bn_mp_or.o 3rdparty/libtommath/bn_mp_prime_fermat.o 3rdparty/libtommath/bn_mp_prime_is_divisible.o 3rdparty/libtommath/bn_mp_prime_is_prime.o 3rdparty/libtommath/bn_mp_prime_miller_rabin.o 3rdparty/libtommath/bn_mp_prime_next_prime.o 3rdparty/libtommath/bn_mp_prime_rabin_miller_trials.o 3rdparty/libtommath/bn_mp_prime_random_ex.o 3rdparty/libtommath/bn_mp_radix_size.o 3rdparty/libtommath/bn_mp_radix_smap.o 3rdparty/libtommath/bn_mp_rand.o 3rdparty/libtommath/bn_mp_read_radix.o 3rdparty/libtommath/bn_mp_read_signed_bin.o 3rdparty/libtommath/bn_mp_read_unsigned_bin.o 3rdparty/libtommath/bn_mp_reduce.o 3rdparty/libtommath/bn_mp_reduce_2k.o 3rdparty/libtommath/bn_mp_reduce_2k_l.o 3rdparty/libtommath/bn_mp_reduce_2k_setup.o 3rdparty/libtommath/bn_mp_reduce_2k_setup_l.o 3rdparty/libtommath/bn_mp_reduce_is_2k.o 3rdparty/libtommath/bn_mp_reduce_is_2k_l.o 3rdparty/libtommath/bn_mp_reduce_setup.o 3rdparty/libtommath/bn_mp_rshd.o 3rdparty/libtommath/bn_mp_set.o 3rdparty/libtommath/bn_mp_set_int.o 3rdparty/libtommath/bn_mp_set_long.o 3rdparty/libtommath/bn_mp_set_long_long.o 3rdparty/libtommath/bn_mp_shrink.o 3rdparty/libtommath/bn_mp_signed_bin_size.o 3rdparty/libtommath/bn_mp_sqr.o 3rdparty/libtommath/bn_mp_sqrmod.o 3rdparty/libtommath/bn_mp_sqrt.o 3rdparty/libtommath/bn_mp_sqrtmod_prime.o 3rdparty/libtommath/bn_mp_sub.o 3rdparty/libtommath/bn_mp_sub_d.o 3rdparty/libtommath/bn_mp_submod.o 3rdparty/libtommath/bn_mp_to_signed_bin.o 3rdparty/libtommath/bn_mp_to_signed_bin_n.o 3rdparty/libtommath/bn_mp_to_unsigned_bin.o 3rdparty/libtommath/bn_mp_to_unsigned_bin_n.o 3rdparty/libtommath/bn_mp_toom_mul.o 3rdparty/libtommath/bn_mp_toom_sqr.o 3rdparty/libtommath/bn_mp_toradix.o 3rdparty/libtommath/bn_mp_toradix_n.o 3rdparty/libtommath/bn_mp_unsigned_bin_size.o 3rdparty/libtommath/bn_mp_xor.o 3rdparty/libtommath/bn_mp_zero.o 3rdparty/libtommath/bn_prime_tab.o 3rdparty/libtommath/bn_reverse.o 3rdparty/libtommath/bn_s_mp_add.o 3rdparty/libtommath/bn_s_mp_exptmod.o 3rdparty/libtommath/bn_s_mp_mul_digs.o 3rdparty/libtommath/bn_s_mp_mul_high_digs.o 3rdparty/libtommath/bn_s_mp_sqr.o 3rdparty/libtommath/bn_s_mp_sub.o 3rdparty/libtommath/bncore.o
moar​::tomrule=$(AR) $(ARFLAGS) $@​ 3rdparty/libtommath/*.o
moar​::translate_newline_output=0
moar​::usrlibs[0]=pthread
moar​::uvclean=$(RM) 3rdparty/libuv/libuv.a $(UV_DARWIN)
moar​::uvlib=3rdparty/libuv/libuv.a
moar​::uvobjects=$(UV_DARWIN)
moar​::uvrule=$(AR) $(ARFLAGS) $@​ $(UV_DARWIN)
moar​::version=2017.07
moar​::versionmajor=2017
moar​::versionminor=07
moar​::versionpatch=0
perl6​::build-date=2017-07-24T19​:31​:35Z
perl6​::codename=
perl6​::implementation=Rakudo
perl6​::language_version=6.c
perl6​::prefix=/Applications/Rakudo
perl6​::release-number=
perl6​::version=2017.07
repo​::chain=file#/Users/andrewbuchanan/Library/usr/lib/perl6 inst#/Users/andrewbuchanan/.perl6 inst#/Applications/Rakudo/share/perl6/site inst#/Applications/Rakudo/share/perl6/vendor inst#/Applications/Rakudo/share/perl6 CompUnit​::Repository​::AbsolutePath.new(next-repo => CompUnit​::Repository​::NQP.new(next-repo => CompUnit​::Repository​::Perl5.new(next-repo => CompUnit​::Repository))) CompUnit​::Repository​::NQP.new(next-repo => CompUnit​::Repository​::Perl5.new(next-repo => CompUnit​::Repository)) CompUnit​::Repository​::Perl5.new(next-repo => CompUnit​::Repository)

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Sep 10, 2017

From @smls

On Fri, 08 Sep 2017 18​:37​:50 -0700, tomentiruran@​gmail.com wrote​:

my @​h
[]
@​h.splice​: 0, 0, 1.Seq
[]
@​h[0].VAR.WHAT
(Int)
@​h[0] = 5
Cannot modify an immutable Int (1)
in block <unit> at <unknown file> line 1

I got hit by this with​: @​a.splice​: 0, 0, Any xx 2

Good find.

It's also not specific to `Seq` - it looks like it happens whenever the replacement elements are passed to `splice` as a nested structure rather than as flat arguments​:

  my @​h;
  @​h.splice​: 0, 0, 'a';
  @​h.splice​: 1, 0, ('b',);

  dd @​h; # Array @​h = ["a", "b"]
  say @​h[0].VAR.^name; # Scalar
  say @​h[1].VAR.^name; # Str

Conceptually¹⁺², the `splice` routine takes the replacements as a `*@​` slurpy, so whether they're passed in nested or flat form should not matter.

But Rakudo currently implements the routine with a `| is raw` signature​:

  say Array.^find_method("splice").signature; # (Mu $​: | is raw)

...and apparently does the parameter flattening manually, in a way that introduces this bug.

Until it is fixed, a work-around is to flatten the replacement elements into the argument list of `splice` using `|`​:

  @​a.splice​: 0, 0, |(Any xx 2);


[1] https://docs.perl6.org/routine/splice
[2] https://design.perl6.org/S32/Containers.html#splice

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Sep 10, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Sep 16, 2017

From @skids

On Sun, 16 Apr 2017 12​:56​:58 -0700, elizabeth wrote​:

Actually reported as a SO question by brian d foy​:

http://stackoverflow.com/questions/43437664/how-can-i-get-around-a-
slurpy-parameter-in-the-perl-6-signature

<lizmat> m​: my @​a = [1,1],[2,2],[3,3]; dd @​a; @​a.splice​: 0, 2,
$[4,4]; dd @​a # feels like a bug that the containerization of [4,4]
is being ignored
<+camelia> rakudo-moar 188711​: OUTPUT​: «Array @​a = [[1, 1], [2,
2], [3, 3]]␤Array @​a = [4, 4, [3, 3]]␤»
<jnthn> lizmat​: Yeah, it's because there's a candidate with @​new at
the end that it binds to, decontainerizing it in the process.
<jnthn> So it's not actually hitting the slurpy at all
<lizmat> so you agree it's wrong atm
<jnthn> The slurpy is **@​foo
<jnthn> So in fact if it *was* hitting the slurpy it would be behaving
right :)
<jnthn> Yeah, it's wrong to discard the itemization
<lizmat> ok, so we are in agreement
<jnthn> I wonder if it was untested and then accidentally regressed
when splice was optimized by breaking it out into a bunch of
candidates
<lizmat> will file a rakudobug
<jnthn> Since I seem to recall splice getting at least something of a
look during the GLR
<jnthn> And I can't imagine we settled on "it ignores itemization" :)
<jnthn> bisectable6​: my @​a = [1,1],[2,2],[3,3]; @​a.splice​: 0, 2,
$[4,4]; dd @​a
<+bisectable6> jnthn, On both starting points (old=2015.12
new=1887114) the exit code is 0 and the output is identical as well
<+bisectable6> jnthn, Output on both points​: «Array @​a = [4, 4, [3,
3]]»
<jnthn> Hm, nope
<jnthn> It's been like that since Christmas
<lizmat> ok, doesn't make it right, though :-)
<jnthn> Indeed
<lizmat> but will wait for the release to look at fixing it
<jnthn> *nod*

This ticket and RT#​132047 may be merged.

Please find an experimental tree at​:
https://github.com/skids/rakudo/tree/rt131162

commit 998738620d1ca327e1b2d7727b7a0f28b9bce542
Author​: skids <bri@​abrij.org>
Date​: Fri Sep 15 21​:01​:48 2017 -0400

  GLR-ize splice's @​replacement argument

  Collapse **@​ and @​ candidates into +@​ candidates.
  This is a spec/doc change. Will need to be reconciled.
  May need to figure out how to make this 6.d-only (or later)
  Amazingly, passes all spectests.
  Fixes RT#​131162 and RT#​132047
  Needs ecosystem-wide testing for fallout

(I also tried **@​ and it did not fair very well. There are many
specttests that assume single-argument-rule behavior on single arguments.)

splice's prototype never got touched during GLR, if you look at git blame
in specs. It just got missed, I guess. Probably not the only one.

If someone who is tooled to do an ecosystem-wide/multiplatform test could
try this tree we could get an idea how disruptive it would be.

Figuring out where this sits WRT 6.d, both feature-wise and technically
as to how we best replace 6.c's Array candidates or dispatcher.

No performance tests have been done on this. I notice we still keep some
core code doing +@​ by hand but don't know if that is due to performance
or just because they were implemented before we had that slurpy modifier,
or due to a needed behavioral quirk.

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Sep 16, 2017

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.