Skip to content

Unable to create distinct tuple in a const with a type declaration #2760

@Perelandric

Description

@Perelandric

This code...

type
  DistTup = distinct tuple
    foo, bar: string

const d: DistTup = DistTup((
  foo:"FOO", bar:"BAR"
))

fails with...

Error: internal error: changeType: no tuple type for constructor
No stack traceback available

But it works with var and let, or if we drop the type declaration or drop the distinct.

Recompiling with ./koch temp c gives...

test.nim(6, 28) Error: internal error: changeType: no tuple type for constructor
Traceback (most recent call last)
nim.nim(94)              nim
nim.nim(56)              handleCmdLine
main.nim(252)            mainCommand
main.nim(63)             commandCompileToC
modules.nim(203)         compileProject
modules.nim(151)         compileModule
passes.nim(197)          processModule
passes.nim(137)          processTopLevelStmt
sem.nim(450)             myProcess
sem.nim(424)             semStmtAndGenerateGenerics
semstmts.nim(1408)       semStmt
semexprs.nim(906)        semExprNoType
semexprs.nim(2218)       semExpr
semstmts.nim(494)        semConst
semstmts.nim(304)        fitRemoveHiddenConv
sem.nim(91)              fitNode
semexprs.nim(451)        changeType
msgs.nim(842)            internalError
msgs.nim(816)            liMessage
msgs.nim(715)            handleError
FAILURE

Nim Compiler Version 0.11.2 (2015-05-15) [Linux: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf

git hash: c30d7c3
active boot switches: -d:release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions