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

Crashes compiling an object (with destructor) construction which is then converted to a distinct type #18570

Closed
alaviss opened this issue Jul 24, 2021 · 0 comments

Comments

@alaviss
Copy link
Collaborator

alaviss commented Jul 24, 2021

Example

type
  O = object
    x: int

proc `=destroy`(o: var O) = discard

type D = distinct O

let d = D O(x: 0)

Current Output

compiler/nim.nim(87) handleCmdLine
compiler/main.nim(275) mainCommand
compiler/main.nim(245) compileToBackend
compiler/main.nim(101) commandCompileToC
compiler/modules.nim(178) compileProject
compiler/modules.nim(98) compileModule
compiler/passes.nim(180) processModule
compiler/passes.nim(73) processTopLevelStmt
compiler/cgen.nim(1938) myProcess
compiler/cgen.nim(1927) genTopLevelStmt
compiler/injectdestructors.nim(1137) injectDestructorCalls
compiler/injectdestructors.nim(610) p
compiler/injectdestructors.nim(879) p
compiler/injectdestructors.nim(1060) moveOrCopy
compiler/injectdestructors.nim(810) p
compiler/types.nim(1662) lookupFieldAgain
lib/system/assertions.nim(39) failedAssertImpl
lib/system/assertions.nim(29) raiseAssert
lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: compiler/types.nim(1662, 11) `ty.kind in {tyTuple, tyObject}`  [AssertionDefect]

Expected Output

Compiles

Additional Information

Bisect identified f851965 to be the first bad commit
/cc @Araq

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-07-24
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: f4ff276a90091f2b88c191aac5a201dcb3ec9795
active boot switches:
@alaviss alaviss changed the title Compiler crashes compiling a tuple unpacking Crashes compiling an object (with destructor) construction which is then converted to a distinct type Jul 25, 2021
alaviss added a commit to alaviss/nim-sys that referenced this issue Jul 25, 2021
@Araq Araq added this to the 1.6.0 milestone Jul 27, 2021
Araq added a commit that referenced this issue Jul 27, 2021
@Araq Araq closed this as completed in c86f959 Jul 27, 2021
PMunch pushed a commit to PMunch/Nim that referenced this issue Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants