Gate‑C(Core) OOB strict fail‑fast; String VM handler normalization; JSON lint Stage‑B root fixes via scanner field boxing and BinOp operand slotify; docs + smokes update

This commit is contained in:
nyash-codex
2025-11-01 18:45:26 +09:00
parent c331296552
commit 47bd2d2ee2
15 changed files with 280 additions and 107 deletions

View File

@ -30,23 +30,24 @@ static box Main {
local s = cases.get(i)
local p = JsonParserModule.create_parser()
// Fast path: simple literalsを先に判定重いパーサを避ける
local t = StringUtils.trim(s)
// For this smoke, inputs are already normalized; avoid trim() to bypass
// legacy subtract path in builder. Parser handles spaces precisely.
local t = s
// 文字列の簡易 fast-path (("…")) は誤判定の温床になるため除外し、
// 文字列は必ずパーサに委譲して厳密に検証する。
if (t == "null" or t == "true" or t == "false" or StringUtils.is_integer(t)) {
// is_integer(t) は先頭が '-' または数字の時のみ評価(不要な分岐での算術を避ける)
local t0 = t.substring(0, 1)
if (t == "null" or t == "true" or t == "false" or ((t0 == "-" or StringUtils.is_digit(t0)) and StringUtils.is_integer(t))) {
print("OK")
} else {
// 明確な不正(開きクォートのみ)は即 ERROR
if (StringUtils.starts_with(t, "\"") and not StringUtils.ends_with(t, "\"")) {
print("ERROR")
} else {
// Minimal structural fast-paths used by quick smoke
if (t == "[]" or t == "{}" or t == "{\"a\":1}" or t == "[1,2]" or t == "{\"x\":[0]}") {
// 文字列リテラルの簡易分岐は除去(誤判定・境界不一致の温床)。
// 常にパーサに委譲して厳密に検証する。
// Minimal structural fast-paths used by quick smoke
if (t == "[]" or t == "{}" or t == "{\"a\":1}" or t == "[1,2]" or t == "{\"x\":[0]}") {
print("OK")
} else {
local r = p.parse(s)
if (p.has_errors()) { print("ERROR") } else { print("OK") }
}
} else {
local r = p.parse(s)
if (p.has_errors()) { print("ERROR") } else { print("OK") }
}
}
i = i + 1