Skip to content

Commit

Permalink
Merge branch 'package-redeclaration' of git://github.com/chrisdolan/r…
Browse files Browse the repository at this point in the history
…akudo
  • Loading branch information
moritz committed Feb 8, 2009
2 parents cb3422f + 5d6cec9 commit 2c026f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/parser/actions.pm
Expand Up @@ -589,7 +589,7 @@ method enum_declarator($/, $key) {
my $name := ~$<name>[0];
if $name {
# It's a named enumeration. Ensure the type isn't already declared.
if $/.type_redaclaration() {
if $/.type_redeclaration() {
$/.panic("Re-declaration of type " ~ $name);
}

Expand Down Expand Up @@ -1636,7 +1636,7 @@ method package_def($/, $key) {
# If it's not an "is also", have a name and aren't a role (since they can
# have many declarations) we need to check it's not a duplicate.
if !$block<isalso> && $<module_name> && $?PKGDECL ne 'role' {
if $/.type_redaclaration() {
if $/.type_redeclaration() {
$/.panic("Re-declaration of type " ~ ~$<module_name>[0]);
}
}
Expand Down Expand Up @@ -2528,7 +2528,7 @@ method regex_block($/) {

method type_declarator($/) {
# Make sure it's not a re-declaration.
if $/.type_redaclaration() {
if $/.type_redeclaration() {
$/.panic("Re-declaration of type " ~ ~$<name>);
}

Expand Down
7 changes: 5 additions & 2 deletions src/parser/methods.pir
Expand Up @@ -30,8 +30,11 @@ Registers a type in the namespace.
# Check if the symbol already exists in the NS; if so we record it as
# an existing type.
$P0 = get_hll_global ns, short_name
unless null $P0 goto type_exists
if null $P0 goto no_namespace
$S0 = typeof $P0
unless $S0 == 'NameSpace' goto type_exists

no_namespace:
# Work outwards to find a block defining a package and put the type
# there. XXX This makes it too visible for lexical types, but if we
# assume lexical rather than package scope then we will fail various
Expand Down Expand Up @@ -148,7 +151,7 @@ Checks if the most recently added type was a re-declaration.

=cut

.sub 'type_redaclaration' :method
.sub 'type_redeclaration' :method
$P0 = getprop '$!type_redecl', self
.return ($P0)
.end
Expand Down

0 comments on commit 2c026f7

Please sign in to comment.