Why is this program valid? I was trying to create a syntax error

后端 未结 6 1292
不思量自难忘°
不思量自难忘° 2020-11-28 17:04

I\'m running ActiveState\'s 32 bit ActivePerl 5.14.2 on Windows 7. I wanted to mess around with a Git pre-commit hook to detect programs being checked in with syntax errors.

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 17:49

    I don't know why, but this is what Perl makes of it:

    perl -MO=Deparse -w yuck
    BEGIN { $^W = 1; }
    use warnings;
    use strict 'refs';
    'error'->Syntax(!exit(0));
    yuck syntax OK
    

    It seems that the parser thinks you're calling the method Syntax on the error-object... Strange indeed!

提交回复
热议问题