From 9a5312bb35af73d7290db5c0e0b03ec97f7a1a95 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Mon, 25 Jul 2022 18:45:36 +0100 Subject: [PATCH] Use documentation names --- Analysis/src/BuiltinDefinitions.cpp | 2 +- Analysis/src/EmbeddedBuiltinDefinitions.cpp | 60 ++++++++++----------- Analysis/src/TypeVar.cpp | 10 ++-- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Analysis/src/BuiltinDefinitions.cpp b/Analysis/src/BuiltinDefinitions.cpp index 394eb9bd..c433d2d4 100644 --- a/Analysis/src/BuiltinDefinitions.cpp +++ b/Analysis/src/BuiltinDefinitions.cpp @@ -221,7 +221,7 @@ void registerBuiltinTypes(TypeChecker& typeChecker) TypeId tableMetaMT = arena.addType(MetatableTypeVar{tabTy, genericMT}); - addGlobalBinding(typeChecker, "getmetatable", makeFunction(arena, std::nullopt, {genericMT}, {}, {tableMetaMT}, {"tbl"}, {genericMT}), "@luau"); + addGlobalBinding(typeChecker, "getmetatable", makeFunction(arena, std::nullopt, {genericMT}, {}, {tableMetaMT}, {"t"}, {genericMT}), "@luau"); // clang-format off // setmetatable(T, MT) -> { @metatable MT, T } diff --git a/Analysis/src/EmbeddedBuiltinDefinitions.cpp b/Analysis/src/EmbeddedBuiltinDefinitions.cpp index 13c59365..dea02610 100644 --- a/Analysis/src/EmbeddedBuiltinDefinitions.cpp +++ b/Analysis/src/EmbeddedBuiltinDefinitions.cpp @@ -20,8 +20,8 @@ declare bit32: { arshift: (n: number, i: number) -> number, rshift: (n: number, i: number) -> number, bnot: (n: number) -> number, - extract: (n: number, position: number, width: number?) -> number, - replace: (n: number, r: number, position: number, width: number?) -> number, + extract: (n: number, f: number, w: number?) -> number, + replace: (n: number, r: number, f: number, w: number?) -> number, countlz: (n: number) -> number, countrz: (n: number) -> number, } @@ -94,8 +94,8 @@ type DateTypeResult = { } declare os: { - time: (time: DateTypeArg?) -> number, - date: (format: string?, time: number?) -> DateTypeResult | string, + time: (t: DateTypeArg?) -> number, + date: (s: string?, t: number?) -> DateTypeResult | string, difftime: (a: DateTypeResult | number, b: DateTypeResult | number) -> number, clock: () -> number, } @@ -115,25 +115,25 @@ declare function type(value: T): string declare function typeof(value: T): string -- `assert` has a magic function attached that will give more detailed type information -declare function assert(value: T, errorMessage: string?): T +declare function assert(value: T, message: string?): T declare function tostring(value: T): string declare function tonumber(value: T, radix: number?): number? declare function rawequal(a: T1, b: T2): boolean -declare function rawget(tab: {[K]: V}, k: K): V -declare function rawset(tab: {[K]: V}, k: K, v: V): {[K]: V} +declare function rawget(t: {[K]: V}, k: K): V +declare function rawset(t: {[K]: V}, k: K, v: V): {[K]: V} declare function setfenv(target: number | (T...) -> R..., env: {[string]: any}): ((T...) -> R...)? -declare function ipairs(tab: {V}): (({V}, number) -> (number, V), {V}, number) +declare function ipairs(t: {V}): (({V}, number) -> (number, V), {V}, number) declare function pcall(f: (A...) -> R..., ...: A...): (boolean, R...) -- FIXME: The actual type of `xpcall` is: -- (f: (A...) -> R1..., err: (E) -> R2..., A...) -> (true, R1...) | (false, R2...) -- Since we can't represent the return value, we use (boolean, R1...). -declare function xpcall(f: (A...) -> R1..., err: (E) -> R2..., ...: A...): (boolean, R1...) +declare function xpcall(f: (A...) -> R1..., e: (E) -> R2..., ...: A...): (boolean, R1...) -- `select` has a magic function attached to provide more detailed type information declare function select(i: string | number, ...: A...): ...any @@ -157,30 +157,30 @@ declare coroutine: { } declare table: { - concat: (tbl: {V}, sep: string?, from: number?, to: number?) -> string, - insert: ((tbl: {V}, value: V) -> ()) & ((tbl: {V}, index: number, value: V) -> ()), - maxn: (tbl: {V}) -> number, - remove: (tbl: {V}, index: number?) -> V?, - sort: (tbl: {V}, f: ((V, V) -> boolean)?) -> (), - create: (size: number, value: V?) -> {V}, - find: (tbl: {V}, value: V, startIndex: number?) -> number?, + concat: (t: {V}, sep: string?, f: number?, t: number?) -> string, + insert: ((t: {V}, value: V) -> ()) & ((t: {V}, i: number, v: V) -> ()), + maxn: (t: {V}) -> number, + remove: (t: {V}, i: number?) -> V?, + sort: (t: {V}, f: ((V, V) -> boolean)?) -> (), + create: (n: number, v: V?) -> {V}, + find: (t: {V}, v: V, i: number?) -> number?, - unpack: (tbl: {V}, from: number?, to: number?) -> ...V, + unpack: (a: {V}, f: number?, t: number?) -> ...V, pack: (...V) -> { n: number, [number]: V }, - getn: (tbl: {V}) -> number, - foreach: (tbl: {[K]: V}, f: (key: K, value: V) -> ()) -> (), - foreachi: (tbl: {V}, f: (index: number, value: V) -> ()) -> (), + getn: (t: {V}) -> number, + foreach: (t: {[K]: V}, f: (key: K, value: V) -> ()) -> (), + foreachi: (t: {V}, f: (index: number, value: V) -> ()) -> (), - move: (tbl: {V}, from: number, to: number, startIndex: number, newTbl: {V}?) -> {V}, - clear: (tbl: {[K]: V}) -> (), + move: (a: {V}, f: number, t: number, d: number, tt: {V}?) -> {V}, + clear: (t: {[K]: V}) -> (), - isfrozen: (tbl: {[K]: V}) -> boolean, + isfrozen: (t: {[K]: V}) -> boolean, } declare debug: { info: ((co: thread, level: number, s: string) -> R...) & ((level: number, s: string) -> R...) & ((f: (A...) -> R1..., s: string) -> R2...), - traceback: ((msg: string?, level: number?) -> string) & ((co: thread, message: string?, level: number?) -> string), + traceback: ((msg: string?, level: number?) -> string) & ((co: thread, msg: string?, level: number?) -> string), } declare utf8: { @@ -188,16 +188,16 @@ declare utf8: { charpattern: string, codes: (str: string) -> ((string, number) -> (number, number), string, number), -- FIXME - codepoint: (str: string, startOffset: number?, endOffset: number?) -> (number, ...number), - len: (str: string, startOffset: number?, endOffset: number?) -> (number?, number?), - offset: (str: string, codepoint: number?, bytePosition: number?) -> number, + codepoint: (s: string, i: number?, j: number?) -> (number, ...number), + len: (s: string, i: number?, j: number?) -> (number?, number?), + offset: (s: string, n: number?, i: number?) -> number, nfdnormalize: (string) -> string, nfcnormalize: (string) -> string, graphemes: (string, number?, number?) -> (() -> (number, number)), } -- Cannot use `typeof` here because it will produce a polytype when we expect a monotype. -declare function unpack(tab: {V}, i: number?, j: number?): ...V +declare function unpack(a: {V}, f: number?, t: number?): ...V )BUILTIN_SRC"; @@ -211,9 +211,9 @@ std::string getBuiltinDefinitionSource() result += "declare function rawlen(obj: {[K]: V} | string): number\n"; if (FFlag::LuauUnknownAndNeverType) - result += "declare function error(message: T, level: number?): never\n"; + result += "declare function error(obj: T, level: number?): never\n"; else - result += "declare function error(message: T, level: number?)\n"; + result += "declare function error(obj: T, level: number?)\n"; return result; } diff --git a/Analysis/src/TypeVar.cpp b/Analysis/src/TypeVar.cpp index 33c0d01c..fb1cd894 100644 --- a/Analysis/src/TypeVar.cpp +++ b/Analysis/src/TypeVar.cpp @@ -766,14 +766,14 @@ TypeId SingletonTypes::makeStringMetatable() const TypePackId stringVariadicList = arena->addTypePack(TypePackVar{VariadicTypePack{stringType}}); const TypePackId numberVariadicList = arena->addTypePack(TypePackVar{VariadicTypePack{numberType}}); - const TypeId stringToStringType = makeFunction(*arena, std::nullopt, {}, {}, {stringType}, {"str"}, {stringType}); + const TypeId stringToStringType = makeFunction(*arena, std::nullopt, {}, {}, {stringType}, {"s"}, {stringType}); const TypeId replArgType = arena->addType( UnionTypeVar{{stringType, arena->addType(TableTypeVar({}, TableIndexer(stringType, stringType), TypeLevel{}, TableState::Generic)), makeFunction(*arena, std::nullopt, {}, {}, {stringType}, {}, {stringType})}}); - const TypeId gsubFunc = makeFunction(*arena, stringType, {}, {}, {stringType, replArgType, optionalNumber}, {"pattern", "replace", "maxs"}, {stringType, numberType}); + const TypeId gsubFunc = makeFunction(*arena, stringType, {}, {}, {stringType, replArgType, optionalNumber}, {"p", "f", "maxs"}, {stringType, numberType}); const TypeId gmatchFunc = - makeFunction(*arena, stringType, {}, {}, {stringType}, {"pattern"}, {arena->addType(FunctionTypeVar{emptyPack, stringVariadicList})}); + makeFunction(*arena, stringType, {}, {}, {stringType}, {"p"}, {arena->addType(FunctionTypeVar{emptyPack, stringVariadicList})}); attachMagicFunction(gmatchFunc, magicFunctionGmatch); const TypeId matchFunc = arena->addType(FunctionTypeVar{arena->addTypePack({stringType, stringType, optionalNumber}), @@ -796,7 +796,7 @@ TypeId SingletonTypes::makeStringMetatable() {"match", {matchFunc}}, {"rep", {makeFunction(*arena, stringType, {}, {}, {numberType}, {"n"}, {stringType})}}, {"reverse", {stringToStringType}}, - {"sub", {makeFunction(*arena, stringType, {}, {}, {numberType, optionalNumber}, {"from", "to"}, {stringType})}}, + {"sub", {makeFunction(*arena, stringType, {}, {}, {numberType, optionalNumber}, {"f", "t"}, {stringType})}}, {"upper", {stringToStringType}}, {"split", {makeFunction(*arena, stringType, {}, {}, {optionalString}, {"sep"}, {arena->addType(TableTypeVar{{}, TableIndexer{numberType, stringType}, TypeLevel{}, TableState::Sealed})})}}, @@ -804,7 +804,7 @@ TypeId SingletonTypes::makeStringMetatable() arena->addTypePack(TypePack{{stringType}, anyTypePack}), oneStringPack, })}}, - {"packsize", {makeFunction(*arena, stringType, {}, {}, {}, {"format"}, {numberType})}}, + {"packsize", {makeFunction(*arena, stringType, {}, {}, {}, {"f"}, {numberType})}}, {"unpack", {arena->addType(FunctionTypeVar{ arena->addTypePack(TypePack{{stringType, stringType, optionalNumber}}), anyTypePack,