From 3be82035bfba2b873e2fd8dfbbf1c5e84c45e31c Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 5 Aug 2020 16:56:59 -0700 Subject: [PATCH] Update lint.md (#4) Add TableLiteral docs --- docs/lint.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/lint.md b/docs/lint.md index dcd4624..e6e9fe4 100644 --- a/docs/lint.md +++ b/docs/lint.md @@ -216,3 +216,15 @@ local str = ("%d %"):format(1, 2) ``` Note that with the exception of `string.format` this only works when the function is called via the library, not via the method call (so prefer `string.match(s, "pattern")` to `s:match("pattern")`). + +## TableLiteral (19) + +Table literals are often used in Luau to create objects or specify data. The syntax for table literals is rich but invites mistakes, for example it allows duplicate keys or redundant index specification for values already present in the list form. This warning is emitted for cases where some entries in the table literal are ignored at runtime as they're duplicate: + +```lua +print({ + first = 1, + second = 2, + first = 3, -- Table field 'first' is a duplicate; previously defined at line 2 +}) +```