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

No check whether operators are overloaded to lvalue functions. #1996

Closed
p5pRT opened this issue May 19, 2000 · 5 comments
Closed

No check whether operators are overloaded to lvalue functions. #1996

p5pRT opened this issue May 19, 2000 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented May 19, 2000

Migrated from rt.perl.org#3270 (status was 'rejected')

Searchable as RT3270$

@p5pRT
Copy link
Author

p5pRT commented May 19, 2000

From abigail@arenanetworks.com

Created by abigail@arena-i.com

  #!/opt/perl/bin/perl

  no warnings;
  use overload '.' => \˙
  sub dot : lvalue {my ($obj, $method) = @​_; $obj -> {$method};}
  my $o = bless {} => "main";

  $o.foo = "bar";
  __END__

This doesn't compile with the error​:

  Can't modify concatenation (.) in scalar assignment at ./overloaded.pl
  line 9, near ""bar";"
  Execution of ./overloaded.pl aborted due to compilation errors.

However, the overloaded operator returns an lvalue, and hence the
assignment ought to work.

Abigail

Perl Info

Flags:
    category=core
    severity=medium

This perlbug was built using Perl v5.6.0 - Thu Mar 23 19:51:19 EST 2000
It is being executed now by  Perl v5.6.0 - Fri Mar 24 17:24:48 EST 2000.

Site configuration information for perl v5.6.0:

Configured by abigail at Fri Mar 24 17:24:48 EST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=i86pc-solaris-64int
    uname='sunos newyork 5.7 generic_106542-07 i86pc i386 i86pc '
    config_args='-d -Dprefix=/opt/perl -Uinstallusrbinperl -Doptimize=-g -Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=2.95.1 19990816 (release)
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /home/abigail/Perl
    /home/abigail/Sybase
    /opt/perl/lib/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/5.6.0
    /opt/perl/lib/site_perl/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/site_perl/5.6.0
    /opt/perl/lib/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/abigail
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/abigail/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/usr/ccs/bin:/usr/openwin/bin:/opt/Acrobat4/bin:/opt/cvs/bin:/opt/perl/bin
    PERL5LIB=/home/abigail/Perl:/home/abigail/Sybase
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2000

From [Unknown Contact. See original ticket]

Created by abigail@arena-i.com

  #!/opt/perl/bin/perl

  no warnings;
  use overload '.' => \˙
  sub dot : lvalue {my ($obj, $method) = @​_; $obj ->
{$method};}
  my $o = bless {} => "main";

  $o.foo = "bar";
  __END__

This doesn't compile with the error​:

  Can't modify concatenation (.) in scalar assignment at ./overloaded.pl
  line 9, near ""bar";"
  Execution of ./overloaded.pl aborted due to compilation errors.

However, the overloaded operator returns an lvalue, and hence the
assignment ought to work.

Abigail

Perl Info

Flags:
    category=core
    severity=medium

This perlbug was built using Perl v5.6.0 - Thu Mar 23 19:51:19 EST 2000
It is being executed now by  Perl v5.6.0 - Fri Mar 24 17:24:48 EST 2000.

Site configuration information for perl v5.6.0:

Configured by abigail at Fri Mar 24 17:24:48 EST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=i86pc-solaris-64int
    uname='sunos newyork 5.7 generic_106542-07 i86pc i386 i86pc '
    config_args='-d -Dprefix=/opt/perl -Uinstallusrbinperl -Doptimize=-g
-Duse64bitint'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=2.95.1 19990816 (release)
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /home/abigail/Perl
    /home/abigail/Sybase
    /opt/perl/lib/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/5.6.0
    /opt/perl/lib/site_perl/5.6.0/i86pc-solaris-64int
    /opt/perl/lib/site_perl/5.6.0
    /opt/perl/lib/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/abigail
    LANG (unset)
    LANGUAGE (unset)
   
LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib
    LOGDIR (unset)
   
PATH=/home/abigail/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/usr/ccs/bin:/usr/openwin/bin:/opt/Acrobat4/bin:/opt/cvs/bin:/opt/perl/bin
    PERL5LIB=/home/abigail/Perl:/home/abigail/Sybase
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2011

From @cpansprout

On Fri May 19 04​:35​:48 2000, abigail@​arenanetworks.com wrote​:

\#\!/opt/perl/bin/perl

no warnings;
use overload '\.' => \\˙
sub dot : lvalue \{my \($obj\, $method\) = @​\_; $obj \-> \{$method\};\}
my $o  = bless \{\} => "main";

$o\.foo = "bar";
\_\_END\_\_

This doesn't compile with the error​:

Can't modify concatenation \(\.\) in scalar assignment at

./overloaded.pl
line 9, near ""bar";"
Execution of ./overloaded.pl aborted due to compilation errors.

However, the overloaded operator returns an lvalue, and hence the
assignment ought to work.

This is partially fixed by commit bf8fb5e. If the $o.foo is changed to
${\($o.foo)} *and* if the returned hash element already exists, it works.

(I know, that barely fixes it at all, but it’s useful to have a trail
explaining how it was fixed.)

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2017

From zefram@fysh.org

The general case that this ticket is about cannot be reasonably made to
work as requested. Overloaded operators are resolved at runtime, so it
is impossible to determine at compile time whether an lvalue method would
be called. The only way to permit the lvalue method to be called and
let the assignment succeed would be to abolish all compile-time checking
of lvalueness for any operator that is capable of being overloaded, and
introduce runtime checks for lvalue context into the implementation of
each of those operators. Either of these downsides would be prohibitive,
and they are certainly not worth it in order to permit a very rare and
dubious application of overloading.

This ticket should be closed. The meta ticket [perl #89650], which
depends on this ticket, can also be closed.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2017

@cpansprout - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant