From 5733b9f74b510f3b7aa6db0b6f0b2fc995de4bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Tue, 16 Jan 2024 14:33:47 +0100 Subject: [PATCH] [language] error on undefined key in struct and table --- anselme/ast/Struct.lua | 2 +- ideas.md | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/anselme/ast/Struct.lua b/anselme/ast/Struct.lua index b7da15b..51712fa 100644 --- a/anselme/ast/Struct.lua +++ b/anselme/ast/Struct.lua @@ -113,7 +113,7 @@ Struct = ast.abstract.Runtime { if v ~= nil then return v else - return Nil:new() + error(("key %q is undefined in %s"):format(key:format(), self.type), 0) end end, get_strict = function(self, key) diff --git a/ideas.md b/ideas.md index 38b26bd..d265bab 100644 --- a/ideas.md +++ b/ideas.md @@ -25,10 +25,6 @@ Issue: dispatch is decided before evaluating default values. Multiline string and comments? ---- - -Error on undefined struct/table key? I copied the Lua behavior but maybe not useful here. - # Can be done later Translation.