Skip to content

[200_21] 升级到Goldfish Scheme v17.11.41#3106

Merged
da-liii merged 2 commits intomainfrom
hxh/200_21/17.11.41
Apr 7, 2026
Merged

[200_21] 升级到Goldfish Scheme v17.11.41#3106
da-liii merged 2 commits intomainfrom
hxh/200_21/17.11.41

Conversation

@wumoin
Copy link
Copy Markdown
Contributor

@wumoin wumoin commented Apr 7, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@da-liii da-liii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@da-liii da-liii merged commit 1c49dc6 into main Apr 7, 2026
2 checks passed
@da-liii da-liii deleted the hxh/200_21/17.11.41 branch April 7, 2026 01:48
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

本次 PR 将 Goldfish Scheme 升级至 v17.11.41,引入了全新的 (liii uri) URI 处理库,并为 path.scm 新增了 path-rename 函数。uri-record.scm 存在一个 P0 级别的严重结构性缺陷:define-library 在第 304 行处提前关闭,导致所有导出的访问器函数(25+ 个,包括 uri-schemeuri-hosturi-port 等)定义在库体之外,调用方导入后将遭遇"未绑定标识符"错误,整个 URI 库完全不可用。uri-predicate.scm 同样存在 begin 块提前关闭(P1)和 uri-default-port? 永远返回 #f(P1)的问题。

Confidence Score: 3/5

本 PR 存在 P0 级别缺陷,uri-record.scm 的结构性错误将导致整个 URI 库在运行时完全不可用,不建议合并

uri-record.scm 中 define-library 提前关闭是通过阅读源代码可直接确认的确定性结构缺陷(P0),uri-predicate.scm 的 begin 结构错误和 uri-default-port? 逻辑错误是明确的 P1 缺陷。这些问题将在运行时直接引发错误,因此置信度为 3/5

uri-record.scm(P0:库结构错误,所有访问器在库外)和 uri-predicate.scm(P1:begin 结构错误、uri-default-port? 逻辑错误、重复定义)需要重点修复

Important Files Changed

Filename Overview
TeXmacs/plugins/goldfish/goldfish/liii/uri-record.scm 严重结构缺陷:define-library 在第 304 行提前关闭,所有访问器函数(25+个)定义在库体之外,导入方无法访问任何导出的访问器
TeXmacs/plugins/goldfish/goldfish/liii/uri-predicate.scm begin 块仅包含 DEFAULT-PORTS 便提前关闭;谓词函数在 begin 外定义;uri-default-port? 永远返回 #f;DEFAULT-PORTS/uri-default-port 与 uri-record.scm 重复定义
TeXmacs/plugins/goldfish/goldfish/liii/uri-parse.scm 解析辅助模块结构正确;parse-netloc 不支持 IPv6 地址格式([::1] 中的冒号会被误识别为端口分隔符)
TeXmacs/plugins/goldfish/goldfish/liii/uri-compare.scm URI 比较模块结构完整;uri-hash 实现极简陋(字符串长度之和),哈希碰撞率极高;间接依赖 uri-record.scm 中有问题的 alist->query-string
TeXmacs/plugins/goldfish/goldfish/liii/uri-make.scm URI 构造模块结构正确,支持标准 URI 和 Git SSH 格式;依赖 uri-record.scm 中有问题的 query-string->alist
TeXmacs/plugins/goldfish/goldfish/liii/uri-transform.scm URI 变换模块结构完整,with- 系列、query 更新、路径操作均已实现;依赖 uri-record.scm 中有问题的 uri-parent 等访问器
TeXmacs/plugins/goldfish/goldfish/liii/uri-convert.scm URI 转换模块结构正确,直接操作原始字段;间接依赖 alist->query-string
TeXmacs/plugins/goldfish/goldfish/liii/uri.scm 门面模块,无实现代码,重新导出所有子模块接口;子模块缺陷将向上传播导致整个 (liii uri) 不可用
TeXmacs/plugins/goldfish/goldfish/liii/path.scm 新增 path-rename 函数,结构完整,已正确添加到 export 列表
TeXmacs/plugins/goldfish/goldfish/liii/base.scm 导出列表精简调整,移除已由 (scheme base) 提供的函数,结构正确
TeXmacs/plugins/goldfish/goldfish/liii/list.scm 清理重复导出项(cons、car、cdr、map、assoc 等已由 scheme base 提供),新增 (scheme base) 导入

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    URI["(liii uri) 门面模块"] --> UP["(liii uri-parse) 解析辅助 OK"]
    URI --> UR["(liii uri-record) 记录类型+访问器\nP0: define-library 第304行提前关闭\n25+个访问器在库体之外"]
    URI --> UPred["(liii uri-predicate) 谓词函数\nP1: begin块提前关闭\nP1: uri-default-port?永远返回false"]
    URI --> UC["(liii uri-compare) 比较函数"]
    URI --> UM["(liii uri-make) 构造函数"]
    URI --> UT["(liii uri-transform) 变换函数"]
    URI --> UCV["(liii uri-convert) 转换函数 OK"]
    UR --> UP
    UPred --> UR
    UC --> UR
    UM --> UR
    UM --> UP
    UT --> UR
    UT --> UP
    UCV --> UR
    UCV --> UP
    style UR fill:#ff4444,color:#fff
    style UPred fill:#ff8800,color:#fff
    style UC fill:#ffe066
    style UM fill:#ffe066
    style UT fill:#ffe066
    style UCV fill:#d4edda
    style UP fill:#d4edda
    style URI fill:#4488ff,color:#fff
Loading

Reviews (1): Last reviewed commit: "wip" | Re-trigger Greptile

Comment on lines +286 to +308
) ;begin

;; alist 转为查询字符串
(define (alist->query-string alist)
(if (null? alist)
""
(string-join
(map (lambda (pair)
(if (cdr pair)
(string-append (car pair) "=" (uri-encode (cdr pair)))
(car pair)
) ;if
) ;map
alist
) ;string-join
"&"
) ;if
) ;define
) ;define-library

;;; ---------- 访问器函数 ----------
;; scheme 访问器
(define (uri-scheme uri-obj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 define-library 提前关闭,所有访问器函数定义在库体之外

define-library 在第 304 行 ) ;define-library 处已关闭,但从第 306 行开始的所有访问器函数(uri-schemeuri-hosturi-porturi-useruri-passworduri-authorityuri-pathuri-queryuri-fragmenturi-parenturi-nameuri-suffixuri-suffixes 等共 25+ 个)都定义在库体之外的全局顶层作用域。这些符号虽在 export 列表中声明,但任何执行 (import (liii uri-record)) 的代码在运行时都将遭遇未绑定标识符错误,使整个 URI 库完全不可用。修复方案:删除第 304 行的 ) ;define-library,将其移至文件末尾,并将所有访问器函数包含在完整的 begin 块内。

Comment on lines +31 to +45
(begin
;;; ---------- 常量定义 ----------
;; 默认端口映射表
(define DEFAULT-PORTS
'(("http" . 80)
("https" . 443)
("ftp" . 21)
("ssh" . 22)
("smtp" . 25)
("dns" . 53)
("pop3" . 110)
("imap" . 143)
("ldap" . 389)
) ;define
) ;begin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 begin 块提前关闭,谓词函数定义在 begin 之外

begin 块在第 45 行 ) ;begin 处关闭,但所有谓词函数(uri-absolute?uri-relative?uri-default-porturi-default-port?uri-network-scheme?,第 47–87 行)都定义在 begin 块之外。根据 R7RS 规范,define-library 中的 define 表达式必须位于 begin 声明中。此外,第 87 行有一个多余的 ) ;define 括号,没有对应的开括号,会导致括号不匹配。修复方案:将 ) ;begin 移至所有谓词函数定义之后,并删除第 87 行多余的括号。

Comment on lines +73 to +82
(define (uri-default-port? uri-obj)
(let* ((scheme (uri-scheme-raw uri-obj))
(explicit-port #f) ; 简化实现,实际需要解析 netloc
(default-port (and scheme (uri-default-port scheme))))
(and default-port
explicit-port
(= explicit-port default-port)
) ;and
) ;let*
) ;define
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 uri-default-port? 永远返回 #f

explicit-port 被硬编码为 #f(第 75 行),导致 (and default-port explicit-port ...) 的结果始终为 #f。该函数已被 (liii uri) 重新导出,调用方会静默地收到错误结果。(liii uri-record) 中已有 uri-explicit-port 访问器可正确获取显式端口。

Suggested change
(define (uri-default-port? uri-obj)
(let* ((scheme (uri-scheme-raw uri-obj))
(explicit-port #f) ; 简化实现,实际需要解析 netloc
(default-port (and scheme (uri-default-port scheme))))
(and default-port
explicit-port
(= explicit-port default-port)
) ;and
) ;let*
) ;define
(define (uri-default-port? uri-obj)
(let* ((scheme (uri-scheme-raw uri-obj))
(explicit-port (uri-explicit-port uri-obj))
(default-port (and scheme (uri-default-port scheme))))
(and default-port
explicit-port
(= explicit-port default-port)
) ;and
) ;let*
) ;define

Comment on lines +344 to +364

;; 默认端口映射表(供 uri-port 使用)
(define DEFAULT-PORTS
'(("http" . 80)
("https" . 443)
("ftp" . 21)
("ssh" . 22)
("smtp" . 25)
("dns" . 53)
("pop3" . 110)
("imap" . 143)
("ldap" . 389)
) ;define
) ;define

;; 获取 scheme 的默认端口
(define (uri-default-port scheme)
(let ((pair (assoc scheme DEFAULT-PORTS)))
(if pair (cdr pair) #f)
) ;let
) ;define
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 DEFAULT-PORTS 和 uri-default-port 与 uri-predicate.scm 重复定义

这两个符号在 uri-predicate.scm(第 34–70 行)和 uri-record.scm(第 346–364 行,且位于库体外)中各有一份定义,并且两个模块的 export 列表都声明了 uri-default-port。若两处定义出现分歧,行为将不一致。修复方案:统一在 uri-predicate.scm 中定义这两个符号,删除 uri-record.scm 中的重复定义,并从其 export 列表中移除 uri-default-port

Comment on lines +63 to +70
(host+port (if (and host-part (string-index host-part #\:))
(let ((colon-pos (string-index host-part #\:)))
(cons (substring host-part 0 colon-pos)
(string->number (substring host-part (+ colon-pos 1) (string-length host-part))))
) ;let
(cons host-part #f)
) ;if
) ;host+port
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 parse-netloc 不支持 IPv6 地址格式

当前逻辑通过检测 host 部分的第一个 : 来分割 host 和 port,但对于 IPv6 URI(如 http://[::1]:8080/path),string-index 会找到 IPv6 地址内部的冒号,导致 host 被错误解析为 "[" 而 port 解析失败。RFC 3986 规定 IPv6 地址必须用方括号包裹,端口分隔符冒号位于右括号之后。建议在分割端口时先判断 host-part 是否以 [ 开头,若是则寻找 ] 之后的冒号作为端口分隔符。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants