bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Namespace issue?

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: BSC (Bluespec Compiler)
View previous topic :: View next topic  

Is this a bug?
Yes
100%
 100%  [ 1 ]
No
0%
 0%  [ 0 ]
Total Votes : 1

Author Message
KernelJ



Joined: 23 Oct 2010
Posts: 1

PostPosted: Tue May 10, 2011 7:22 pm    Post subject: Namespace issue? Reply with quote

I found after defining a struct called Update, which worked ok, when I had StmtFSM imported, it had overridden my local definition for anywhere I tried to use the struct constructor Update (though the type still worked).

For example following code won't compile:
Code:
import StmtFSM::*;

typedef struct {t x;} Update#(type t) deriving (Bits,Eq);

module mkUpdateBug(Empty);
   Update#(int) u = Update{x: 55};
endmodule: mkUpdateBug


The error you get is:
Code:
Error: "UpdateBug.bsv", line 6, column 21: (T0080)
  Type error at the use of the following function:
    Update

  The expected return type of the function:
    UpdateBug::Update#(Int#(32))

  The return type according to the use:
    StmtFSM::ActionType

make: *** [UpdateBug.bo] Error 1


Tested on Bluespec Compiler, version 2011.05.beta1 (build 23970, 2011-05-04)
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 495

PostPosted: Wed Jun 29, 2011 2:38 pm    Post subject: Re: Namespace issue? Reply with quote

Thank you for reporting this example.

Note that you can add a qualifier to the struct, to specify which one you want, when there are multiple options:

let u = PackageName::Update { x: 55 };

If there are two types with the same constructor name, and you don't give a qualifier to identify which one you want, BSC has to pick one. (It happens that, in this case, one of those is inside a Library package.) BSC usually picks the one whose type is appropriate, so I'm surprised that it picked the one from StmtFSM in this example. It is a reasonable enhancement to have BSC pick the one that is defined in the current package -- however, you'd still have the problem if you moved "Update" to another package and imported it.

It's probably the case that StmtFSM should not be exporting "Update", which would also fix your name clash.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: BSC (Bluespec Compiler) All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP