E033: Package Duplicate Symbol

This error is emitted when you try to define a nested package with the same name as an existing type (class or trait) in the same parent package.

Package names must be unique and cannot conflict with type definitions in the same scope.

Note: This error requires package statements which cannot be demonstrated in Scaladoc's snippet compiler. The examples below show the code structure but are not compiled.


Example

package foo:
  trait id:
    def bar: Int

package foo:
  package id:  // error: Trying to define package with same name as trait id
    class Bar

Error

-- [E033] Naming Error: example.scala:6:10 -------------------------------------
6 |  package id:  // error: Trying to define package with same name as trait id
  |          ^^
  |          Trying to define package with same name as trait id

Solution

Use a different package name to avoid conflict with the type:

// Use a different package name
package foo:
  trait id:
    def bar: Int

package foo:
  package idPkg:
    class Bar

Or rename the trait to avoid conflict:

// Or rename the trait to avoid conflict
package foo:
  trait IdTrait:
    def bar: Int

package foo:
  package id:
    class Bar