added check if custom func already exists

This commit is contained in:
Thomas von Dein
2020-04-13 18:15:38 +02:00
parent 0cba681c99
commit 763a9fd9f4

17
rpnc
View File

@@ -556,14 +556,17 @@ sub defun {
return;
}
if (grep {$name eq $_} keys %commands) {
print "reserved function name (command)!\n";
return;
}
if (! exists $custom{$name}) {
# no need to check twice and overwriting of custom function must be legal
if (grep {$name eq $_} keys %commands) {
print "reserved function name (command)!\n";
return;
}
if (grep {$name eq $_} keys %func) {
print "reserved function name (function)!\n";
return;
if (grep {$name eq $_} keys %func) {
print "reserved function name (function)!\n";
return;
}
}
$custom{$name} = "@tokens";