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

`syntax error' message not trapped by $SIG{__DIE__} #1504

Closed
p5pRT opened this issue Mar 25, 2000 · 5 comments
Closed

`syntax error' message not trapped by $SIG{__DIE__} #1504

p5pRT opened this issue Mar 25, 2000 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 25, 2000

Migrated from rt.perl.org#2718 (status was 'resolved')

Searchable as RT2718$

@p5pRT
Copy link
Author

p5pRT commented Mar 25, 2000

From @mjdominus

Created by @mjdominus

Here's a sample program​:

  #!/usr/bin/perl

  sub foo {
  print "TRAPPED MESSAGE $_[0]\n";
  exit 0;
  }

  BEGIN { $SIG{__DIE__} = \&foo }

  1+(2*3;

When run with 5.005_03 or 5.6.0, this yields​:

  syntax error at test.pl line 5, near "3;"
  TRAPPED MESSAGE Execution of test.pl aborted due to compilation errors.

I want the `syntax error' message to be trapped also. The discussion
of $SIG{__DIE__} in `perlvar' suggests that it should be trapped​:

  `__DIE__'/`__WARN__' handlers are very special in
  one respect​: they may be called to report (proba-
  ble) errors found by the parser. In such a case
  the parser may be in inconsistent state

Perl Info


Site configuration information for perl 5.00503:

Configured by mjd at Sun Jan 23 14:15:22 EST 2000.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.12, archname=i586-linux
    uname='linux plover 2.2.12 #10 mon nov 1 17:02:09 est 1999 i586 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.90.29 980515 (egcs-1.0.3 release)
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    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
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /shlib /lib /usr/lib
    libs=-lndbm -lgdbm -ldbm -ldb -ldl -lm -lc
    libc=/lib/libc.so.6, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/lib/perl5/5.00503/i586-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i586-linux
    /usr/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/home/mjd
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/mjd/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11/bin:/usr/games:/sbin:/usr/sbin:/usr/local/bin/X11:/usr/local/bin/mh:/data/mysql/bin:/home/mjd/TPI/bin:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2000

From [Unknown Contact. See original ticket]

mjd@​plover.com writes​:

    sub foo \{ 
      print "TRAPPED MESSAGE $\_\[0\]\\n";
      exit 0;
    \}

    BEGIN \{ $SIG\{\_\_DIE\_\_\} = \\&foo \}

    1\+\(2\*3;

When run with 5.005_03 or 5.6.0, this yields​:

    syntax error at test\.pl line 5\, near "3;"
    TRAPPED MESSAGE Execution of test\.pl aborted due to compilation errors\.

I want the `syntax error' message to be trapped also. The discussion
of $SIG{__DIE__} in `perlvar' suggests that it should be trapped​:

           \`\_\_DIE\_\_'/\`\_\_WARN\_\_' handlers are very special in
           one respect​: they may be called to report \(proba\-
           ble\) errors found by the parser\.  In such a case
           the parser may be in inconsistent state

Did you try setting __WARN__ handler? Or maybe you want your Perl
compiler exit after one error? ;-) [Was this changed recently?]

Ilya

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2000

From [Unknown Contact. See original ticket]

Ilya Zakharevich wrote​:

Did you try setting __WARN__ handler? Or maybe you want your Perl
compiler exit after one error? ;-) [Was this changed recently?]

It was changed for strict warnings so that they can be caught in eval.
That was change 4197. For instance,

  use strict;
  eval q{
  $x = 1;
  foo;
  } or print "Caught​:[$@​]";

now prints "Caught​:[Global symbol..." etc. Much nicer than before.

...searching perldelta...

=head2 All compilation errors are true errors

Some "errors" encountered at compile time were by neccessity
generated as warnings followed by eventual termination of the
program. This enabled more such errors to be reported in a
single run, rather than causing a hard stop at the first error
that was encountered.

The mechanism for reporting such errors has been reimplemented
to queue compile-time errors and report them at the end of the
compilation as true errors rather than as warnings. This fixes
cases where error messages leaked through in the form of warnings
when code was compiled at run time using C<eval STRING>, and
also allows such errors to be reliably trapped using C<eval "...">.

I infer from this that $SIG{__DIE__} should also now be getting all
these, just like $@​ is.

--
Rick Delaney
rick.delaney@​home.com

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 2002

From @floatingatoll

[mjd@​plover.com - Sat Mar 25 14​:25​:36 2000]​:

When run with 5.005_03 or 5.6.0, this yields​:

    syntax error at test\.pl line 5\, near "3;"
    TRAPPED MESSAGE Execution of test\.pl aborted due to

compilation errors.

I want the `syntax error' message to be trapped also. The discussion
of $SIG{__DIE__} in `perlvar' suggests that it should be trapped​:

This issue appears to have been resolved, as of the 5.8/5.9 development track​:

TRAPPED MESSAGE syntax error at 2718.pl line 12, near "3;"

Thanks for the bug report!

- R.

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 2002

@floatingatoll - Status changed from 'open' to 'resolved'

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