This forum has been archived. Please start a new discussion on GitHub.

Duplicate naming error while running slice2java

I would appreciate your help in understanding why this is not supported or what am I doing wrong.


My sample ice file is
[COLOR="Blue"]#ifndef TEST_ICE
#define TEST_ICE

module com
    module xxx
        module data
            module testsomething
                module service
                    interface TestSomething
                        int         getPoints();
                    interface TestSomethingHandler
                        TestSomething* getSomething(string name );



When I run slice2java I get following error

slice2java --output-dir c:\myproj\src c:\myproj\ice\
c:\\myproj\\ice\\ interface name `testsomething' cannot differ only in capitalization from enclosing module `testsomething' (first defined at c:\\myproj\\ice\\
c:\\myproj\\ice\\ module name `TestSomething' is capitalized inconsistently with its previous name: `::com::xxx::data::testsomething'
c:\\myproj\\ice\\ `TestSomething' is not a type


  • mes
    mes California

    When you declared the module testsomething, you introduced that symbol into the enclosing scope. Slice does not permit you to introduce another symbol that differs only in capitalization (such as TestSomething) into the same scope, or into any nested scope. You'll need to rename the module or the interface.

    Take care,
    - Mark
  • By the way, initially, the rule what as that only immediately nested scopes could not have the same name because that can cause problems with constructors in many languages.

    Later, we made the rule more strict to prohibit scopes with the same name anywhere along the nesting chain because of C#: prior to C# 2.0, there was no way to anchor a symbol lookup at the global scope so, if you had nested scopes with the same name, anything outside the inner scope became inaccessible from within the inner scope.

    If we ever get to the point where we drop support for C# 1.0, we can relax this rule again. However, as a general point, I would still discourage having nested scopes with the same name as a matter of style--the potential for confusion this creates is almost certainly worse than having to use unique names for nested scopes.


  • Gentlemen,

    Thanks for the update and explaining me the reasoning behind the situation.