Useless use of constant value

Hi All,

C:\NtUtil>perl6 -v
This is Rakudo Star version 2019.03.1 built on MoarVM
version 2019.03 implementing Perl 6.d for Windows


What am I doing wrong here?

<WinVer.pm6>
unit module WinVer;
# WinVer.pm6

sub WinVer() is export( :WinVer ) {
#`{
       Reference: https://www.gaijin.at/en/infos/windows-version-numbers

       Return a string with the name of the Windows version:

}

    my %Ver = (
       "5.10"       => "Windows XP",
       "6.10"       => "Windows 7",
       "6.20"       => "Windows 8",
       "6.30"       => "Windows 8.1",
       "10.0.10240" => "Windows 10-1507",
       "10.0.10586" => "Windows 10-1511",
       "10.0.14393" => "Windows 10-1607",
       "10.0.16299" => "Windows 10-1709",
       "10.0.17134" => "Windows 10-1803",
       "10.0.17763" => "Windows 10-1607",
       "10.0.18362" => "Windows 10-1903",
       "10.0.18363" => "Windows 10-1909" );

    my Str $RtnStr;
    my Str $Version;

    say %Ver;
    # $RtnStr = qx ( ver );
    # for %Ver -> $Key  {
    #    say $Key;
    # }

}
</WinVer.pm6>


C:\NtUtil>perl6 -e "use lib 'C:\NtUtil'; use WinVer :WinVer; WinVer;"

WARNINGS for -e:
Useless use of constant value WinVer in sink context (line 1)
0
perl6
11/28/2019 4:07:27 AM
perl.perl6.users 1266 articles. 0 followers. Follow

2 Replies
11 Views

Similar Articles

[PageSpeed] 33

Try naming the sub a different name from the class.  For some reason =
"WinVer" is referring to the "WinVer" type object, instead of the WinVer =
sub.  This may be a case of DIHWIDT, or a bug, not sure.

> On 28 Nov 2019, at 05:07, ToddAndMargo via perl6-users =
<perl6-users@perl.org> wrote:
>=20
> Hi All,
>=20
> C:\NtUtil>perl6 -v
> This is Rakudo Star version 2019.03.1 built on MoarVM
> version 2019.03 implementing Perl 6.d for Windows
>=20
>=20
> What am I doing wrong here?
>=20
> <WinVer.pm6>
> unit module WinVer;
> # WinVer.pm6
>=20
> sub WinVer() is export( :WinVer ) {
> #`{
>      Reference: https://www.gaijin.at/en/infos/windows-version-numbers
>=20
>      Return a string with the name of the Windows version:
>=20
> }
>=20
>   my %Ver =3D (
>      "5.10"       =3D> "Windows XP",
>      "6.10"       =3D> "Windows 7",
>      "6.20"       =3D> "Windows 8",
>      "6.30"       =3D> "Windows 8.1",
>      "10.0.10240" =3D> "Windows 10-1507",
>      "10.0.10586" =3D> "Windows 10-1511",
>      "10.0.14393" =3D> "Windows 10-1607",
>      "10.0.16299" =3D> "Windows 10-1709",
>      "10.0.17134" =3D> "Windows 10-1803",
>      "10.0.17763" =3D> "Windows 10-1607",
>      "10.0.18362" =3D> "Windows 10-1903",
>      "10.0.18363" =3D> "Windows 10-1909" );
>=20
>   my Str $RtnStr;
>   my Str $Version;
>=20
>   say %Ver;
>   # $RtnStr =3D qx ( ver );
>   # for %Ver -> $Key  {
>   #    say $Key;
>   # }
>=20
> }
> </WinVer.pm6>
>=20
>=20
> C:\NtUtil>perl6 -e "use lib 'C:\NtUtil'; use WinVer :WinVer; WinVer;"
>=20
> WARNINGS for -e:
> Useless use of constant value WinVer in sink context (line 1)
0
liz
11/28/2019 4:50:47 AM
>> On 28 Nov 2019, at 05:07, ToddAndMargo via perl6-users <perl6-users@perl.org> wrote:
>>
>> Hi All,
>>
>> C:\NtUtil>perl6 -v
>> This is Rakudo Star version 2019.03.1 built on MoarVM
>> version 2019.03 implementing Perl 6.d for Windows
>>
>>
>> What am I doing wrong here?
>>
>> <WinVer.pm6>
>> unit module WinVer;
>> # WinVer.pm6
>>
>> sub WinVer() is export( :WinVer ) {
>> #`{
>>       Reference: https://www.gaijin.at/en/infos/windows-version-numbers
>>
>>       Return a string with the name of the Windows version:
>>
>> }
>>
>>    my %Ver = (
>>       "5.10"       => "Windows XP",
>>       "6.10"       => "Windows 7",
>>       "6.20"       => "Windows 8",
>>       "6.30"       => "Windows 8.1",
>>       "10.0.10240" => "Windows 10-1507",
>>       "10.0.10586" => "Windows 10-1511",
>>       "10.0.14393" => "Windows 10-1607",
>>       "10.0.16299" => "Windows 10-1709",
>>       "10.0.17134" => "Windows 10-1803",
>>       "10.0.17763" => "Windows 10-1607",
>>       "10.0.18362" => "Windows 10-1903",
>>       "10.0.18363" => "Windows 10-1909" );
>>
>>    my Str $RtnStr;
>>    my Str $Version;
>>
>>    say %Ver;
>>    # $RtnStr = qx ( ver );
>>    # for %Ver -> $Key  {
>>    #    say $Key;
>>    # }
>>
>> }
>> </WinVer.pm6>
>>
>>
>> C:\NtUtil>perl6 -e "use lib 'C:\NtUtil'; use WinVer :WinVer; WinVer;"
>>
>> WARNINGS for -e:
>> Useless use of constant value WinVer in sink context (line 1)

On 2019-11-27 20:50, Elizabeth Mattijsen wrote:
 > Try naming the sub a different name from the class.  For
 > some reason "WinVer" is referring to the "WinVer" type
 > object, instead of the WinVer sub.  This may be a case
 > of DIHWIDT, or a bug, not sure.
 >

Hi Elizabeth,

I got the "Big Guns" helping me!  :-)

I got it to work by comments out the first line
    #  unit module WinVer;

????????  Bug or feature? This is running in
Windows after all.

Thank you for the help!

-T

<WinVer>
# unit module WinVer;
# WinVer.pm6

sub WinVer() is export( :WinVer ) {
#`{
       Reference: https://www.gaijin.at/en/infos/windows-version-numbers

       Return a string with the name of the Windows version:

}

    my %Ver = (
       "5.1"        => "Windows XP",
       "6.1"        => "Windows 7",
       "6.2"        => "Windows 8",
       "6.3 "       => "Windows 8.1",
       "10.0.10240" => "Windows 10-1507",
       "10.0.10586" => "Windows 10-1511",
       "10.0.14393" => "Windows 10-1607",
       "10.0.16299" => "Windows 10-1709",
       "10.0.17134" => "Windows 10-1803",
       "10.0.17763" => "Windows 10-1607",
       "10.0.18362" => "Windows 10-1903",
       "10.0.18363" => "Windows 10-1909" );
    # say %Ver;

    my Str $RtnStr;
    my Str $Version = "";

    $RtnStr = qx ( ver );
    # say $RtnStr;

    for %Ver.kv -> $Key, $Value  {
       if $RtnStr.contains( $Key )  { $Version = $Value; }
    }

    say $Version;
    # return $Version;
}
</WinVer>


C:\NtUtil>perl6 -e "use lib 'K:\Windows\NtUtil'; use WinVer :WinVer; 
WinVer;"

Windows 10-1909

I love hashes!
0
perl6
11/28/2019 5:10:19 AM
Reply: