{"atom":"regression/uint-type-constraint","family":"regression","slug":"uint-type-constraint","header":{"atom":"regression/uint-type-constraint","kind":"whole-program — a minimal repro, not yet reduced to an atom","source":"curated"},"axes":null,"cols":null,"engines":["rakudo-2026.07","rakupp-3.14.0"],"kinds":["ref","pp"],"defFrom":"rakupp:t/regression/uint-type-constraint.raku","counts":{"a":1,"f":0,"d":0,"c":0,"r":0,"n":0},"files":["atoms/regression/uint-type-constraint.grid"],"records":[["0001","","# Reported: github.com/ash/rakupp/issues/11 — a `UInt` parameter rejected every\n# Int it was handed (\"expected UInt but got Int (15)\"), so a MAIN signature like\n# `UInt :$pipeline = 15` could not be called at all. The DEFAULT bound fine, which\n# is what made it confusing: only an explicitly-passed value went through the\n# type check.\n#\n# UInt is `subset UInt of Int where * >= 0`, so it is not a plain name match: a\n# non-negative Int satisfies it, a negative Int does not, and a Rat never does.\n# typeMatchesArg owns that rule; the smartmatch path asks it rather than\n# restating it.\n# Contract: exit 0 + last line PASS.\nmy @fail;\nsub check($got, $want, $what) { @fail.push(\"$what: got $got want $want\") unless $got eq $want }\n\nsub named(UInt :$p = 15) { \"p=$p\" }\ncheck(named(),      'p=15', 'a UInt named param takes its default');\ncheck(named(:p(3)), 'p=3',  'and an explicitly passed value');\ncheck(named(:p(0)), 'p=0',  'zero included');\n\nsub positional(UInt $x) { \"g=$x\" }\ncheck(positional(7), 'g=7', 'a UInt positional binds');\n\ncheck((15 ~~ UInt).gist,   'True',  'smartmatch: a positive Int');\ncheck((0 ~~ UInt).gist,    'True',  'smartmatch: zero');\ncheck((-1 ~~ UInt).gist,   'False', 'smartmatch: a negative Int does NOT match');\ncheck((2.5 ~~ UInt).gist,  'False', 'smartmatch: a Rat does not match');\ncheck((1000000000000000000000 ~~ UInt).gist, 'True',  'a bigint does');\ncheck((-1000000000000000000000 ~~ UInt).gist,'False', 'and a negative bigint does not');\n\n# the constraint is enforced, not merely accepted\nmy $threw = False;\ntry { positional(-1); CATCH { default { $threw = True } } }\n@fail.push('a negative argument was not rejected') unless $threw;\n\nmy UInt $v = 5;\ncheck($v.gist, '5', 'a UInt container holds a value');\n\nif @fail { note \"FAILED: @fail.join('; ')\"; say 'FAIL' } else { say 'PASS' }","output PASS","a",["PASS","PASS"],0,[["budget","20s"]]]]}