-
Notifications
You must be signed in to change notification settings - Fork 34
append函数的问题 #619
Copy link
Copy link
Open
Description
问题根源
这是 Goldfish Scheme 的 append 函数实现有 bug,当使用 append 构建长列表时(约 500+ 个元素),列表结构会损坏变成 dotted pair。
复现代码
(let loop ((entries (map (lambda (i) (cons (number->string i) (list "lib"))) (iota 1000)))
(visible '()))
(if (null? entries)
visible
(let* ((entry (car entries))
(function-name (car entry)))
(loop (cdr entries)
(if (not (member function-name visible))
(append visible (list function-name)) ; 这里会失败
visible)))))
错误信息
;append first argument, ("0" "1" "2" ...), is a pair but should be a proper list
影响
- gf doc "string-spli" 模糊匹配功能无法使用
- 任何使用 append 循环构建长列表的代码都会失败
- visible-function-names 函数在函数数量超过阈值时崩溃
需要修复的地方
Goldfish Scheme 的底层 append 实现(可能在 s7.c 或 base.scm 中)需要修复。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels