Skip to content

Commit 5ddb575

Browse files
committed
Error out when the pattern is not found
1 parent dce8a0c commit 5ddb575

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/luasm.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,13 @@ function instruction:parse(elements, luasm)
186186

187187
local args = {}
188188
for i = 2, #elements do
189-
-- TODO: If structure element does not exist in settings
190-
local arg = elements[i]:match(luasm.settings.syntax[expected[i - 1]])
189+
local pattern = luasm.settings.syntax[expected[i - 1]]
190+
if pattern == nil then
191+
error("The pattern with the name of '" .. expected[i - 1] .. "' does not exist.", 2)
192+
return "Pattern not found"
193+
end
194+
195+
local arg = elements[i]:match(pattern)
191196
if arg == nil then
192197
local err = string.format(
193198
"Could not match argument '%s' (expected %s)",

0 commit comments

Comments
 (0)