Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#330 NiceSlice can get confused by comments to cause compilation errors

critical
open
nobody
None
5
2013-04-22
2013-04-22
dima
No

I hit another NiceSlice bug. I'm attaching a small perl program. It should "perl -c" just fine, however:

dima@shorty:/tmp$ perl -c /tmp/niceslice_significantcomment.pl

Possible unintended interpolation of @x in string at /tmp/niceslice_significantcomment.pl line 10.
syntax error at /tmp/niceslice_significantcomment.pl line 9, near "1:"
Global symbol "@x" requires explicit package name at /tmp/niceslice_significantcomment.pl line 10.
/tmp/niceslice_significantcomment.pl had compilation errors.

Surprisingly enough, the culprit is the comment on line 6. This is confusing NiceSlice. Removing that comment makes it work.

Discussion

  • Chris Marshall
    Chris Marshall
    2013-04-22

    I don't see the attachment but the current PDL::NiceSlice filter doesn't ignore quoted strings or comments. NiceSlice-ish code in them are filtered or can confuse the filter. I have worked out the various issues but ran into various snags in implementation (some from bugs in needed dependencies and some from how to support niceslice filtering in the PDL shells) so it did not make the cut for PDL-2.006.

     
  • dima
    dima
    2013-04-22

    OK; it sounds like you're already familiar with these issues already. I'll attach the sample file anyway (I did attach it when posting; maybe SF is confused).

    Thanks.

     
  • Chris Marshall
    Chris Marshall
    2013-04-22

    Modifying your example to actually do something:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    #!/usr/bin/perl
    use strict;
    use warnings;
    use PDL;
    use PDL::NiceSlice;
    # $f(
    
    my $p = sequence(7);
    my @x = $p->(1:-1)->list;
    print "@x\n";
    

    and this is with the current Filter::Util::Call sourcefilter engine:

    $ perl niceslice_significantcomment.pl
    Possible unintended interpolation of @x in string at niceslice_significantcomment.pl line 10.
    syntax error at niceslice_significantcomment.pl line 9, near "1:"
    Global symbol "@x" requires explicit package name at niceslice_significantcomment.pl line 10.
    Execution of niceslice_significantcomment.pl aborted due to compilation errors.
    

    BUT this is with the current Filter::Simple engine which is mostly working:

    $ PDL_NICESLICE_ENGINE=Filter::Simple perl niceslice_significantcomment.pl 
    1 2 3 4 5 6
    

    Voila! It mostly works but not yet 100%. Nor does it work in the PDL shells.

    --Chris