Skip to content

Bug in parse-to-list ? #18

@syll-dev

Description

@syll-dev

(parse-to-list str) is equivalent to (node->nodelist (parse str)).

if (parse str) fails to read the xml document and returns nil, parse-to-list fails with an unclear error message :

* (parse-to-list "iueiueieiueiu")

debugger invoked on a SB-KERNEL:CASE-FAILURE @54B0750F in thread
#<THREAD tid=49815 "main thread" RUNNING {10048381D3}>:
  NIL fell through ETYPECASE expression. Wanted one of (STRING NODE).

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(NODE->NODELIST NIL)
   source: (ETYPECASE NODE
             (STRING NODE)
             (NODE
              (LIST*
               (IF (NODE-NS NODE)
                   (CONS (NODE-NAME NODE) (NODE-NS NODE))
                   (NODE-NAME NODE))
               (NODE-ATTRS NODE)
               (MAPCAR 'NODE->NODELIST (NODE-CHILDREN NODE)))))

The result is the same with this call :

(parse-to-list "iueiueieiueiu" :quash-errors nil)

Could replacing handler-case with ignore-errors in function parse fix the problem ?

(parse "iueiueieiueiu") returns nil.
(parse "iueiueieiueiu" :quash-errors nil) returns nil.
(parse "iueiueieiueiu" :quash-errors t) returns nil.

Is this the intended behaviour ?

Should (node->nodelist nil) return nil ? It fails with the error above for now.

When parse returns nil, should parse-to-list return nil ?

Should (parse-to-list nil) be strictly equivalent to (node->nodelist (parse str)) for convenience or return nil / signal a clearer error when parse returns nil ?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions