Skip to content

Commit

Permalink
clean up warnings on undefined things
Browse files Browse the repository at this point in the history
  • Loading branch information
TimToady committed May 10, 2015
1 parent 20c3ae3 commit 221b981
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ Compilation unit '$file' contained the following violations:
# push the else block if any, otherwise 'if' returns C<Nil> (per S04)
$past.push( $<else>
?? pblock_immediate( $<else>.ast )
!! QAST::WVal.new( :value($*W.find_symbol(['Nil'])) )
!! QAST::WVal.new( :value($*W.find_symbol(['Empty'])) )
);
# build if/then/elsif structure
while $count > 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/core/CompUnitRepo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ sub PARSE-INCLUDE-SPEC(Str:D $spec, Str:D $default-short-id = 'file') {
]?
$<path>=.+
$/ {
( ~$<type> || $default-short-id, %options, ~$<path> );
( $<type> ?? ~$<type> !! $default-short-id, %options, ~$<path> );
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/Mu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,20 @@ my class Mu { # declared in BOOTSTRAP

proto method Numeric(|) { * }
multi method Numeric(Mu:U \v:) {
warn "use of uninitialized value of type {self.^name} in numeric context";
warn "Use of uninitialized value of type {self.^name} in numeric context";
0
}
proto method Real(|) { * }
multi method Real(Mu:U \v:) {
warn "use of uninitialized value of type {self.^name} in numeric context";
warn "Use of uninitialized value of type {self.^name} in numeric context";
0
}

proto method Str(|) { * }
multi method Str(Mu:U \v:) {
my $name = (defined($*VAR_NAME) ?? $*VAR_NAME !! v.VAR.?name) // '';
$name ~= ' ' if $name ne '';
warn "use of uninitialized value {$name}of type {self.^name} in string context";
warn "Use of uninitialized value {$name}of type {self.^name} in string context";
''
}
multi method Str(Mu:D:) {
Expand Down
13 changes: 12 additions & 1 deletion src/core/Nil.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
my class Nil is Cool { # declared in BOOTSTRAP
method new(*@) { Nil }
method gist(*@) { 'Nil' }
method Str(*@) { '' } # XXX still needs warning
method Numeric() { warn "Use of Nil in numeric context"; 0 }
method Str() { warn "Use of Nil in string context"; '' }
method sink(*@) { Nil } # required by RESTRICTED setting

method AT-POS(*@) { Nil }
Expand All @@ -18,9 +19,19 @@ my class Nil is Cool { # declared in BOOTSTRAP
method FALLBACK(*@) { Nil }
}

# Like Nil, but allows a failsoft to nothingness when used as list.
#
# (Please avoid overusing Empty as a synonym for (). If the degenerate
# case of a list operation is naturally (), use () as a normal defined
# value. Empty is primarily intended for use in list comprehensions,
# which need to weed out unselected values with an implicit "else".)
my class Empty is Nil {
# class Empty is Iterator
method new(*@) { Empty }
multi method Bool() { False }
multi method Int() { 0 }
multi method end() { -1 }
multi method Numeric() { 0 }
method Str() { '' }
method gist(*@) { 'Empty' }
method iterator(*@) { self }
Expand Down

0 comments on commit 221b981

Please sign in to comment.