Export to GitHub

frege - issue #2

It's not possible to name a package org.foo.C.


Posted on May 19, 2011 by Grumpy Rabbit

What steps will reproduce the problem? 1. package xy.C where ... 2. 3.

What is the expected output? What do you see instead?

javac complains

build\C.java:56: C is already defined in ... public static interface C {

Please use labels and text to provide additional information.

Comment #1

Posted on May 19, 2011 by Grumpy Rabbit

This is caused by the interface C { ... } which is nested in the outer class. This interface is built by the compiler as namespace for constants.

Probable fix: in code generation make sure that this name never conflicts with the package name.

Workaround: don't call a package just C.

Comment #2

Posted on May 21, 2011 by Grumpy Rabbit

The problem is even more complex, because as the Java Language Specification states in section 8.1: A compile-time error occurs if a class has the same simple name as any of its enclosing classes or interfaces.

Therefore, also the following program fails:

{{{ package TS where

data S = M | O }}}

Comment #3

Posted on May 21, 2011 by Grumpy Rabbit

And the following fails too:

package DX where

data D = M | O | TS | X Int

Comment #4

Posted on May 22, 2011 by Grumpy Rabbit

Fix posted with revision 138. This change is not backward compatible, it invalidates all code compiled so far. Therefore, a new frege3...jar will be uploaded.

Status: Fixed

Labels:
Type-Defect Priority-Low Usability