History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-591
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Rodrigo B. de Oliveira
Reporter: Sorin Ionescu
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Name resolution fails if a type in the current namespace has the same name as one in an imported namespace

Created: 05/Nov/05 07:01 PM   Updated: 21/Apr/08 05:05 AM
Component/s: None
Affects Version/s: 0.7.5
Fix Version/s: 0.8.1

Time Tracking:
Not Specified

Environment: .NET 2.0 RTM


 Description  « Hide
namespace Alpha

class Foo:
....pass

interface INeeded:
....pass

namespace Bravo:

import Alpha

class Foo:
....pass

class Bar(Foo, INeeded):
....pass

Error: Type 'Foo' is invalid. <--- NOTICE that it does not say 'Ambiguous reference'.
The fix is to specify the Full name of the type: Bravo.Foo, but when you got Boo.Lang.Useful.Pipelines.Documentation.Ast.Node, it's horrible.
BOO should look and resolve types in the current namespace before it looks in other namespaces.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Cameron Kenneth Knight - 05/Nov/05 07:33 PM
The test above doesn't cut it:

// File: Alpha.boo
namespace Alpha

class Foo:
pass

interface INeeded:
pass

// File: BravoAlternate.boo
namespace Bravo:

class Foo:
pass

// File: Bravo.boo
namespace Bravo

import Alpha

class Bar(Foo, INeeded):
pass


Doug H - 07/Nov/05 04:14 PM
One way to temporarily fix this, in src/boo.lang.compiler/typesystem/nameresolutionservice.cs in the ResolveSimpleTypeReference method.

At the line that says:
if (null == info || EntityType.Type != info.EntityType)

Add this BEFORE that line:

if (null != info && EntityType.Ambiguous == info.EntityType)

{ IEntity[] entities = ((Ambiguous)info).Entities; info = entities[entities.Length-1]; node.Name = info.FullName; }

I also added an overload of the ResolveQualifiedName method that takes an entitytype, but that is not called in this particular test.
I changed:
info = ResolveQualifiedName(node.Name);
to
info = ResolveQualifiedName(node.Name, EntityType.Type);
and that overloaded method looks like:
public IEntity ResolveQualifiedName(string name, EntityType flags)

{ _buffer.Clear(); ResolveQualifiedName(_buffer, name, flags); return GetEntityFromBuffer(); }

Doug H - 07/Nov/05 10:24 PM
Also, I'm just guessing, but if you want to create and use classes with the same names and namespaces as those in boo.lang.compiler or other automatically referenced assemblies, you could have outside assemblies inserted at the beginning of the list instead of adding them to the end.
Change this in the sources for booc, booi, and the initializenameresolutionservices step:
Parameters.References.Add(asm);
to Parameters.References.Insert(0, asm) or whatever

Cedric Vivier - 21/Apr/08 05:05 AM
Correctly outputs "Ambiguous reference" since 0.8.1