Skip to content

ORC AssertionDefect not containsManagedMemory(n.typ) #19250

@jackhftang

Description

@jackhftang

The following code failed to compile with --gc:orc

Example

type Bar[T] = object err: proc(): string Foo[T] = object run: proc(): Bar[T] proc bar[T](err: proc(): string): Bar[T] = assert not err.isNil Bar[T](err: err) proc foo*(): Foo[char] = result.run = proc(): Bar[char] = # works # result = Bar[char](err: proc(): string = "x") # not work result = bar[char](proc(): string = "x") proc bug*[T](fs: Foo[T]): Foo[T] = result.run = proc(): Bar[T] = let res = fs.run() # works # var errors = @[res.err]  # not work var errors: seq[proc(): string] errors.add res.err return bar[T] do () -> string: for err in errors: result.add res.err() assert bug(foo()).run().err() == "x"

Current Output

Fail to compile with the following assertion defect.

Error: unhandled exception: injectdestructors.nim(467, 13) `not containsManagedMemory(n.typ)` [AssertionDefect] 

Expected Output

should compile.

Possible Solution

  • There are two places commented in the above example showing a little change could work-around the assertion. But I cannot make sense with those workarounds. Probably some assumptions inside orc do not meet.

Additional Information

run with

nim r --gc:orc test.nim

Tested with 1.6.0 and devel of nim.

$ nim -v Nim Compiler Version 1.7.1 [Linux: amd64] Compiled at 2021-12-14 Copyright (c) 2006-2021 by Andreas Rumpf git hash: 0ff4b2ba7ee74ed2758b0eb5992e4ccab7433952 active boot switches: -d:release 
$ nim -v Nim Compiler Version 1.6.0 [Linux: amd64] Compiled at 2021-10-19 Copyright (c) 2006-2021 by Andreas Rumpf git hash: 727c6378d2464090564dbcd9bc8b9ac648467e38 active boot switches: -d:release 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions