Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape percentage signs for some more fields #923

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10315,6 +10315,8 @@ a.types[i], b.types[i]), }
end
end

local keyg = key:gsub('%%', '%%%%')

if t.fields then
assert(t.fields, "record has no fields!?")

Expand All @@ -10330,12 +10332,12 @@ a.types[i], b.types[i]), }

if rec.kind == "variable" then
if t.typename == "interface" then
return nil, "invalid key '" .. key .. "' in '" .. rec.tk .. "' of interface type %s"
return nil, "invalid key '" .. keyg .. "' in '" .. rec.tk .. "' of interface type %s"
else
return nil, "invalid key '" .. key .. "' in record '" .. rec.tk .. "' of type %s"
return nil, "invalid key '" .. keyg .. "' in record '" .. rec.tk .. "' of type %s"
end
else
return nil, "invalid key '" .. key .. "' in type %s"
return nil, "invalid key '" .. keyg .. "' in type %s"
end
elseif t.typename == "emptytable" or is_unknown(t) then
if self.feat_lax then
Expand All @@ -10345,9 +10347,9 @@ a.types[i], b.types[i]), }
end

if rec.kind == "variable" then
return nil, "cannot index key '" .. key .. "' in variable '" .. rec.tk .. "' of type %s"
return nil, "cannot index key '" .. keyg .. "' in variable '" .. rec.tk .. "' of type %s"
else
return nil, "cannot index key '" .. key .. "' in type %s"
return nil, "cannot index key '" .. keyg .. "' in type %s"
end
end

Expand Down Expand Up @@ -10612,7 +10614,7 @@ a.types[i], b.types[i]), }
local field_names = sorted_keys(rb.enumset)
for _, k in ipairs(field_names) do
if not ra.fields[k] then
errm, erra = "enum value '" .. k .. "' is not a field in %s", ra
errm, erra = "enum value '" .. k:gsub('%%', '%%%%') .. "' is not a field in %s", ra
break
end
end
Expand Down
14 changes: 8 additions & 6 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -10315,6 +10315,8 @@ do
end
end

local keyg = key:gsub('%%', '%%%%')

if t is RecordLikeType then
assert(t.fields, "record has no fields!?")

Expand All @@ -10330,12 +10332,12 @@ do

if rec.kind == "variable" then
if t is InterfaceType then
return nil, "invalid key '" .. key .. "' in '" .. rec.tk .. "' of interface type %s"
return nil, "invalid key '" .. keyg .. "' in '" .. rec.tk .. "' of interface type %s"
else
return nil, "invalid key '" .. key .. "' in record '" .. rec.tk .. "' of type %s"
return nil, "invalid key '" .. keyg .. "' in record '" .. rec.tk .. "' of type %s"
end
else
return nil, "invalid key '" .. key .. "' in type %s"
return nil, "invalid key '" .. keyg .. "' in type %s"
end
elseif t is EmptyTableType or is_unknown(t) then
if self.feat_lax then
Expand All @@ -10345,9 +10347,9 @@ do
end

if rec.kind == "variable" then
return nil, "cannot index key '" .. key .. "' in variable '" .. rec.tk .. "' of type %s"
return nil, "cannot index key '" .. keyg .. "' in variable '" .. rec.tk .. "' of type %s"
else
return nil, "cannot index key '" .. key .. "' in type %s"
return nil, "cannot index key '" .. keyg .. "' in type %s"
end
end

Expand Down Expand Up @@ -10612,7 +10614,7 @@ do
local field_names: {string} = sorted_keys(rb.enumset)
for _, k in ipairs(field_names) do
if not ra.fields[k] then
errm, erra = "enum value '" .. k .. "' is not a field in %s", ra
errm, erra = "enum value '" .. k:gsub('%%', '%%%%') .. "' is not a field in %s", ra
break
end
end
Expand Down
Loading