SWI-Prolog / packages-swipy

Python interface for SWI-Prolog
41 stars 5 forks source link

Fix curly braces #5

Closed kamahen closed 8 months ago

kamahen commented 8 months ago

This showed up when I was changing doc2tex.pl to parse additional C/C++ function calls. Following is the crash I got (but why didn't the catch_with_backtrace/3 produce a backtrace?)

cd /home/peter/src/swipl-devel/build/packages/swipy && /home/peter/src/swipl-devel/build/src/swipl -f none --no-packs /home/peter/src/swipl-devel/build/home/library/ext/ltx2htm/latex2html.pl -- --quiet janus && /usr/bin/cmake -E remove /home/peter/src/swipl-devel/build/home/doc/manindex.db
ERROR: put_html_token/1: instantiation error
   Redo: (1,353) tex:write_html(nospace([])) ? 20g
  [1,353] tex:write_html(nospace([]))
  [1,352] tex:write_html([nospace([])])
  [1,351] tex:write_html([[nospace([])], nospace(')')])
  [1,349] tex:write_html([[nospace('('), [nospace([])], nospace(')')]])
  [1,347] tex:write_html([[py_dict_as, [nospace('('), [nospace([])], nospace(')')]], html('</b>')])
  [1,344] tex:write_html([lref(func, 'py_dict_as()', [py_dict_as, [nospace('('), [nospace(...)], nospace(...)]]), html('</code>'), html('</td>'), html('</tr>'), html('<tr>'), html('<td>'), lref(..., ..., ...)|...])
     [16] tex:run_latex2html('/home/peter/src/swipl-devel/build/packages/swipy/janus.tex')
     [15] tex:latex2html(janus, [quiet(true)])
     [12] catch_with_backtrace('<garbage_collected>', '<garbage_collected>', '<garbage_collected>')
     [11] tex:main('<garbage_collected>')
      [9] catch_with_backtrace('<garbage_collected>', '<garbage_collected>', '<garbage_collected>')
      [8] prolog_main:main
      [5] run_init_goal('<garbage_collected>', @(tex:main, '/home/peter/src/swipl-devel/build/home/library/ext/ltx2htm/latex2html.pl':3227))
kamahen commented 8 months ago

This problem occurred because I expanded the definition of tr//1 in doc2lex.pl to cover most C and C++ functions, not just those starting with PL_* or S* (https://github.com/SWI-Prolog/swipl-devel/pull/1229).

This resulted in expanding the py_dict_as({{}}) inside \exam{py_dict_as({{}})} and the {} (or {{}}) wasn't expanded because the tr//1 rule doesn't recursively expand the args (doc2tex.pl doesn't seem to do anything with \exam, so I don't know where it's expanded).

kamahen commented 8 months ago

doc2lex.pl is the appropriate place to fix this.