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

unexported type aliases in imported module visible when using newSeq #19074

Open
shirleyquirk opened this issue Oct 30, 2021 · 1 comment
Open

Comments

@shirleyquirk
Copy link
Contributor

Example

lib.nim

type
  Hidden = int
proc unexported() =
  var unused = newSeq[Hidden](0)

main.nim

import lib
var x = newSeq[int](1)
echo typeof(x)
let c = x[0]
echo typeof(c)

Current Output

please check whether the problem still exists in git head before posting,
see rebuilding the compiler.

seq[Hidden]
Hidden

Expected Output

seq[int]
int

unearthed by https://forum.nim-lang.org/t/8561
caused user no end of confusion when an unexported (and undocumented) type in a dependency of a dependency was being printed in an error message.

behaviour exist in 1.6,1.4,1.2,1.0,0.20...

$ nim -v

Nim Compiler Version 1.7.1 [Linux: amd64]
Compiled at 2021-10-30
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: f755e45

@Araq
Copy link
Member

Araq commented Oct 30, 2021

More and more I'm off the opinion that we should "cache" generic instantiations only so far as required to prevent endless recursions in instantiations and then in a pre-linking step merge duplicated instantiations. This is what Borland C++ did with C++ templates and I don't remember complaints. It's conceptually simple and worked well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants