rakudo icon indicating copy to clipboard operation
rakudo copied to clipboard

Regex loses identity when used in whatever code in module

Open Leont opened this issue 5 years ago • 0 comments

The Problem

Given the following Foo.rakumod

my Regex $regex = /ab/;
subset Foo where * === $regex;
sub foo is export {
    say $regex ~~ Foo;
}

and the following script foo.raku:

use Foo;
foo();

$regex will lose its identity, and therefor not work as expected.

Expected Behavior

It should print True

Actual Behavior

It prints False

It wll print True if either:

  1. The code is put in foo.raku itself
  2. If $regex is made constant
  3. If the WhateverCode is converted into a block { $^value == $regex }.

It is not affected by no precompilation;, and $regex.WHICH will return the same value inside and outside sub foo.

Environment

Welcome to Rakudo(tm) v2020.12.
Implementing the Raku(tm) programming language v6.d.
Built on MoarVM version 2020.12.

Leont avatar Dec 24 '20 12:12 Leont