Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118851 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32049 invoked from network); 19 Oct 2022 17:09:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Oct 2022 17:09:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DFBCF180044 for ; Wed, 19 Oct 2022 10:09:01 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 19 Oct 2022 10:09:01 -0700 (PDT) Received: by mail-ed1-f52.google.com with SMTP id t16so6989012edd.2 for ; Wed, 19 Oct 2022 10:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uX4oXneSdOjZuau7BDlKOiSZCLnLmbqNTmTQExLlvQE=; b=fBrBoMFLFKmleaWrSCdUI0K08BXzwijR2YcK0ef5l13rC5TDYJG44SfTdgnn/r2QsX b+VcKXx1A/eT5mropbPBGeFyklit2OdxPXRfiaMu8HePrYjB874G9aN8zDw18lGpLTgI SCqO7ClYyZ/SWkpLmncu0iEbwrknvpk4FIQa3AgMDQiUP7CaF5BMfqHiU6igi7GMH9D6 hv7xWMMju51OTYM/zPz1syfyxeb0UnF85VWw7U+qznWlPxM8XCeRTDl3c0efSqMnfyb/ UN5Mr6dlrUM0cf3u24H+698Y3UKnjstt/0pFrcOB/jnfI8VfBE8jn5XItjOPqsiLAwiq zQbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uX4oXneSdOjZuau7BDlKOiSZCLnLmbqNTmTQExLlvQE=; b=YshskOt/554HhBSTAOAXZg/yCHkGW7QeUH7f/QTjDug5h1YFdhJ8MmRBZaMqLEN4U4 t0NZZYp7RGDNRj/g4NrYuVOGpz0VauH+LzZy5Dz/GDqTEpqegQuFIJhCTTZGtgasgnEJ RvDfWzx3PdtSvcrnI0zKY8VHaYJY4nqWm5b3+z7A8g0iVyyCJ1ItqpS5o+k59P/Qlc0z HFS5XYuKIRtOeZ0EyHY5cnfdM6TZ/K3VM9IpRWH9iIesnIBoA0SoA9SYHhnFfMCdHMeG GIcb5C3TY1fH/p7bwa88s88Qn1Bne6DMgqR4x9TD3gzlrCmlo3bfHCZECEmn+JAc3fS4 TM4A== X-Gm-Message-State: ACrzQf1KqKG/myCj0cDxX04nIc1XRD8Nk+Bof3ruuRkCKD9phN+p7K8V pCmJ537TwnKomSYc9//+/Yecnvt2DCNRgV3jH8Cge7hTQSg= X-Google-Smtp-Source: AMsMyM5kJNuQCHhaTkviRvKGbyWN2TSWa37pYg0mIpi2E8ln847OhTREy3Jz7pdGyWxOb1t8afQra3G4oey6dW4z1sw= X-Received: by 2002:aa7:cc90:0:b0:458:b07c:f35f with SMTP id p16-20020aa7cc90000000b00458b07cf35fmr8212240edt.310.1666199339857; Wed, 19 Oct 2022 10:08:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 19 Oct 2022 19:08:47 +0200 Message-ID: To: David Rodrigues Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000c7133705eb664317" Subject: Re: [PHP-DEV] Compact can't resolve outer scoped variables using short closures From: ocramius@gmail.com (Marco Pivetta) --000000000000c7133705eb664317 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 19 Oct 2022, 19:04 David Rodrigues, wrote: > Hello! > > I'm converting my code to use short closures where possible, and I ran in= to > a problem using compact(). > > Basically, the names used in compact() cannot be accessed due to a bug, > reported in 2019 still in PHP 7.4 (ID 78970). > > https://bugs.php.net/bug.php?id=3D78970 > > It seems to me to be a reasonable problem and one that needs attention, a= s > the message is not that "compact cannot be used here", but that "the > variable does not exist". > > The code below may reproduce the problem: > > $x =3D 123; > (fn() =3D> compact('x'))(); > > https://3v4l.org/AFARs > > Is there any possibility of this being fixed? I would love to help, but I > don't have much C programming skills, unfortunately. > I'd rather hope for `compact()` to finally be deprecated and targeted for removal =F0=9F=98=9B The fact that it still exists precludes (or at least complicates) future optimization of scope + inlining in the engine. Similar thoughts towards `extract()`, I'd say. --000000000000c7133705eb664317--