xmlparser.parseXml is not recognised as GC-safe #4899

Closed
goldenreign opened this Issue Oct 15, 2016 · 0 comments

Projects

None yet

2 participants

@goldenreign
Contributor
goldenreign commented Oct 15, 2016 edited
Nim Compiler Version 0.15.1 (2016-10-15) [Linux: amd64]
git hash: 2d2b1a9d481bffaecac35e1e52929cea66f69e0e

This code:

import threadpool
import streams
import xmlparser
import xmltree

proc parseXmlProc() {.gcsafe.} =
  let xmlExample = """
    <data>
      <element>Text</element>
    </data>
  """
  let xmlRoot = xmlExample.newStringStream.parseXml
  echo xmlRoot

proc main() =
  spawn parseXmlProc()
  sync()

when isMainModule:
  main()

Compiles with this error:

lib/nim/pure/xmlparser.nim(50, 6) Warning: 'parse' is not GC-safe as it calls 'untilElementEnd' [GcUnsafe2]                          
lib/nim/pure/xmlparser.nim(103, 6) Warning: 'parseXml' is not GC-safe as it calls 'parse' [GcUnsafe2]                                
lib/nim/pure/xmlparser.nim(123, 6) Warning: 'parseXml' is not GC-safe as it calls 'parseXml' [GcUnsafe2]                             
parsexmltest.nim(6, 6) Error: 'parseXmlProc' is not GC-safe as it calls 'parseXml'

If I add {.gcsafe.} pragma to forward declaration of parse function then code compiles.

@Araq Araq added the Showstopper label Oct 18, 2016
@Araq Araq added a commit that closed this issue Oct 19, 2016
@Araq Araq fixes #4899 a12f503
@Araq Araq closed this in a12f503 Oct 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment