Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document that Packages can be nested in <empty> package #13520

Open
cache-nez opened this issue Sep 14, 2021 · 4 comments
Open

document that Packages can be nested in <empty> package #13520

cache-nez opened this issue Sep 14, 2021 · 4 comments
Labels
area:documentation area:tasty-format issues relating to TASTy as a portable standard

Comments

@cache-nez
Copy link
Contributor

Example code:

import scala.mutable.List

package apackage {
    type AType
}

Corresponding .tasty file:

 0: PACKAGE(124)
 2:   TERMREFpkg 1 [<empty>]
 4:   IMPORT(6)
 6:     SELECT 2 [collection]
 8:       TERMREFpkg 3 [scala]
10:     IMPORTED 4 [Seq]
12:   PACKAGE(112)
14:     TERMREFpkg 5 [apackage]
16:     VALDEF(18) 6 [EmptyPackage$package]
19:       IDENTtpt 7 [EmptyPackage$package[ModuleClass]]
21:         TYPEREFsymbol 36
23:           TERMREFpkg 5 [apackage]
25:       APPLY(8)
27:         SELECTin(6) 11 [<init>[Signed Signature(List(),apackage.EmptyPackage$package$/T) @<init>]]
30:           NEW
31:             SHAREDterm 19
33:           SHAREDtype 21
35:       OBJECT
36:     TYPEDEF(88) 7 [EmptyPackage$package[ModuleClass]]
39:     ....

i.e. apackage is nested in <empty> package, as indicated by indentation and the addresses: <empty> package continues until address 124.

@cache-nez cache-nez added itype:bug area:tasty-format issues relating to TASTy as a portable standard labels Sep 14, 2021
@dwijnand dwijnand removed the area:tasty-format issues relating to TASTy as a portable standard label Sep 14, 2021
@dwijnand dwijnand changed the title In TASTy, packages can be nested in <empty> package Packages can be nested in <empty> package Sep 14, 2021
@dwijnand
Copy link
Member

This isn't specific to TASTy, and I'm not sure if it's a bug or not. @odersky, wdty?

I looked at this in #13113 where I left some notes. Also, @som-snytt's spent time on this, see also his #7891 and #13114.

@odersky
Copy link
Contributor

odersky commented Sep 14, 2021

I think it's a bug. Will take a look.

@dwijnand
Copy link
Member

I think the change, or at least the start of the change, is making parser return Thicket(pkgP, pkgQ) instead of the empty package with packages p and q inside.

I remember reading about this in gkossakowski/kentuckymule#6 (comment).

@odersky
Copy link
Contributor

odersky commented Sep 14, 2021

It's a representation choice. With the current representation, we need the additional rule that normal packages are never members of the empty package, even if they are defined in it. So you could say that empty package on the outside of a tree signals "no package was given, therefore, nested packages go to the root package and all other nested definitions go to the empty package". I think that's a defensible representation choice, and it's not worth breaking Tasty compatibility in order to change it. But we might want to update the Tasty documentation to mention this fact.

@odersky odersky removed their assignment Sep 14, 2021
@odersky odersky added area:documentation area:tasty-format issues relating to TASTy as a portable standard and removed itype:bug labels Sep 14, 2021
@bishabosha bishabosha changed the title Packages can be nested in <empty> package document that Packages can be nested in <empty> package Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:documentation area:tasty-format issues relating to TASTy as a portable standard
Projects
None yet
Development

No branches or pull requests

3 participants