From cfee87d9129c13a2fd2fa649b5963ebb22e8749a Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 8 Feb 2022 23:12:49 -0800 Subject: [PATCH] Update library.md Clarify the relationship between `typeof` and `newproxy`. As a sandboxing measure, `typeof` only uses `__type` on host-defined userdata. Fixes #351. --- docs/_pages/library.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/_pages/library.md b/docs/_pages/library.md index 834bd73b..7695762d 100644 --- a/docs/_pages/library.md +++ b/docs/_pages/library.md @@ -128,7 +128,8 @@ Returns the type of the object, which is one of `"nil"`, `"boolean"`, `"number"` function typeof(obj: any): string ``` -Returns the type of the object; for userdata objects that have a metatable with the `__type` field, returns the value for that key. +Returns the type of the object; for userdata objects that have a metatable with the `__type` field *and* are defined by the host with an internal tag, returns the value for that key. +For custom userdata objects, such as ones returned by `newproxy`, this function returns `"userdata"` to make sure host-defined types can not be spoofed. ``` function ipairs(t: table):