@thigasdevelopment/luam 0.7.0 → 0.8.0

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.
Files changed (2) hide show
  1. package/luam.mjs +14 -1
  2. package/package.json +1 -1
package/luam.mjs CHANGED
@@ -5944,7 +5944,7 @@ import { tmpdir } from "node:os";
5944
5944
  import { join as join2 } from "node:path";
5945
5945
 
5946
5946
  // src/cli/version.ts
5947
- var VERSION = true ? "0.7.0" : "0.0.0-dev";
5947
+ var VERSION = true ? "0.8.0" : "0.0.0-dev";
5948
5948
  var PROGRAM_NAME = "luam";
5949
5949
  var PROGRAM_DESCRIPTION = "luam \u2014 the Luam compiler for Multi Theft Auto resources.";
5950
5950
 
@@ -11782,6 +11782,11 @@ function scopeLabel(environment) {
11782
11782
  return environment === "shared" ? "shared" : `${environment}-only`;
11783
11783
  }
11784
11784
  function checkGlobalReference(context, name, position2) {
11785
+ if (name === "self") {
11786
+ const message2 = 'A "self" is only bound inside a class method or a "function Name:method()"; here it reads a global that is "nil".';
11787
+ context.report("check-invalid-self", message2, position2);
11788
+ return;
11789
+ }
11785
11790
  const project = context.projectEnvironmentOf(name);
11786
11791
  if (project !== null) {
11787
11792
  const message2 = `"${name}" is declared by the project, is ${scopeLabel(project)}, and is not available in a "${context.environment}" file.`;
@@ -12427,6 +12432,13 @@ function fieldType(context, member) {
12427
12432
  }
12428
12433
  return declared;
12429
12434
  }
12435
+ function checkFieldName(context, member) {
12436
+ if (member.name !== "constructor") {
12437
+ return;
12438
+ }
12439
+ const message = 'A "constructor" is the class constructor, not a field. Write it as "constructor = function (...) ... end" or rename the field.';
12440
+ context.report("check-invalid-constructor", message, member.position);
12441
+ }
12430
12442
  function generatedMethodType(member, fieldTypes) {
12431
12443
  const fieldType2 = [...fieldTypes].find(([field2]) => field2.position.offset === member.position.offset)?.[1] ?? ANY_TYPE;
12432
12444
  return member.parameters.length === 0 ? createFunction([], fieldType2) : createFunction([fieldType2], VOID_TYPE);
@@ -12435,6 +12447,7 @@ function registerMembers(context, info, statement) {
12435
12447
  const fieldTypes = /* @__PURE__ */ new Map();
12436
12448
  for (const member of statement.members) {
12437
12449
  if (member.kind === "class-field") {
12450
+ checkFieldName(context, member);
12438
12451
  fieldTypes.set(member, fieldType(context, member));
12439
12452
  }
12440
12453
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thigasdevelopment/luam",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "The Luam compiler for Multi Theft Auto resources.",
5
5
  "keywords": [
6
6
  "mta",