@thigasdevelopment/luam 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/luam.mjs +15 -1
- package/package.json +1 -1
package/luam.mjs
CHANGED
|
@@ -4512,6 +4512,7 @@ function parseReturnStatement(stream) {
|
|
|
4512
4512
|
const position2 = stream.expect("keyword", "return").position;
|
|
4513
4513
|
const stop = stream.isEof() || stream.check("punctuation", "}") || stream.current().kind === "keyword" && BLOCK_END.has(stream.current().value);
|
|
4514
4514
|
const values = stop || stream.check("punctuation", ";") ? [] : parseExpressionList(stream);
|
|
4515
|
+
stream.match("punctuation", ";");
|
|
4515
4516
|
return { kind: "return-statement", values, position: position2 };
|
|
4516
4517
|
}
|
|
4517
4518
|
function parseTypeAlias(stream) {
|
|
@@ -5944,7 +5945,7 @@ import { tmpdir } from "node:os";
|
|
|
5944
5945
|
import { join as join2 } from "node:path";
|
|
5945
5946
|
|
|
5946
5947
|
// src/cli/version.ts
|
|
5947
|
-
var VERSION = true ? "0.
|
|
5948
|
+
var VERSION = true ? "0.8.1" : "0.0.0-dev";
|
|
5948
5949
|
var PROGRAM_NAME = "luam";
|
|
5949
5950
|
var PROGRAM_DESCRIPTION = "luam \u2014 the Luam compiler for Multi Theft Auto resources.";
|
|
5950
5951
|
|
|
@@ -11782,6 +11783,11 @@ function scopeLabel(environment) {
|
|
|
11782
11783
|
return environment === "shared" ? "shared" : `${environment}-only`;
|
|
11783
11784
|
}
|
|
11784
11785
|
function checkGlobalReference(context, name, position2) {
|
|
11786
|
+
if (name === "self") {
|
|
11787
|
+
const message2 = 'A "self" is only bound inside a class method or a "function Name:method()"; here it reads a global that is "nil".';
|
|
11788
|
+
context.report("check-invalid-self", message2, position2);
|
|
11789
|
+
return;
|
|
11790
|
+
}
|
|
11785
11791
|
const project = context.projectEnvironmentOf(name);
|
|
11786
11792
|
if (project !== null) {
|
|
11787
11793
|
const message2 = `"${name}" is declared by the project, is ${scopeLabel(project)}, and is not available in a "${context.environment}" file.`;
|
|
@@ -12427,6 +12433,13 @@ function fieldType(context, member) {
|
|
|
12427
12433
|
}
|
|
12428
12434
|
return declared;
|
|
12429
12435
|
}
|
|
12436
|
+
function checkFieldName(context, member) {
|
|
12437
|
+
if (member.name !== "constructor") {
|
|
12438
|
+
return;
|
|
12439
|
+
}
|
|
12440
|
+
const message = 'A "constructor" is the class constructor, not a field. Write it as "constructor = function (...) ... end" or rename the field.';
|
|
12441
|
+
context.report("check-invalid-constructor", message, member.position);
|
|
12442
|
+
}
|
|
12430
12443
|
function generatedMethodType(member, fieldTypes) {
|
|
12431
12444
|
const fieldType2 = [...fieldTypes].find(([field2]) => field2.position.offset === member.position.offset)?.[1] ?? ANY_TYPE;
|
|
12432
12445
|
return member.parameters.length === 0 ? createFunction([], fieldType2) : createFunction([fieldType2], VOID_TYPE);
|
|
@@ -12435,6 +12448,7 @@ function registerMembers(context, info, statement) {
|
|
|
12435
12448
|
const fieldTypes = /* @__PURE__ */ new Map();
|
|
12436
12449
|
for (const member of statement.members) {
|
|
12437
12450
|
if (member.kind === "class-field") {
|
|
12451
|
+
checkFieldName(context, member);
|
|
12438
12452
|
fieldTypes.set(member, fieldType(context, member));
|
|
12439
12453
|
}
|
|
12440
12454
|
}
|