Skip to content

Conversation

@Hoblovski
Copy link
Collaborator

现有代码仍然不稳定 (issue #33 ),同样输入输出不同………………

一个问题是 (issue #44 ) 里的重名函数,这个一直我们都没说怎么修(没定义正确行为),所以直接先不考虑了。

另一个还是遍历没写对,导致不同顺序带来不同结果的问题

PR desc

现有的代码逻辑如下

func exportSymbol(sym):
	if sym in visited:
		return visited[sym], nil
	...
	id = make_id(sym)
	visited[sym] = id
	if !loadExternal:
		return nil, error("external")
	...
	id, err = exportSymbol(dep)

考虑 a 和其依赖 dep,并且 dep 是外部符号所以会被 loadExternal 筛出去

如果访问顺序是 a, dep,那么会

	exportSymbol(a)
		exportSymbol(dep)
			visited[dep] = id
			return nil, error
		# a 看到的 dep 没有 id,报错了

如果反过来,是

	exportSymbol(dep)
		visited[dep] = id
		return nil, error
	exportSymbol(a)
		exportSymbol(dep)
			return visited[dep], nil
		# a 看到的 dep 有 id,而且没有报错

这样,前者会导致 dep 不会出现在最终的 FunctionCall 里,但后者会出现。

They lead to output instabilities. We *should* fix the instabilities
instead, but for now let's ignore the case.
@AsterDY AsterDY merged commit b6480ac into main Jul 30, 2025
2 checks passed
@Hoblovski Hoblovski deleted the fix/stability branch August 15, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants