Skip to content

Add option to allow error messages to use __type metafield on luau if set over the type name #576

Open
@cheesycod

Description

@cheesycod

This normally doesn't matter much unless the userdata struct itself is generic. E.g.

pub struct Foo<T: FooerTrait> {
   pub foo: T
}

impl LuaUserData for Foo<T> {
  <some code here that defines methods and fields, particularly a __type metamethod on Luau>
}

In luau, ops like type() and even the debug display will use __type correctly however argument conversion errors (forgetting to use method syntax etc) uses the full type name instead of the __type metamethod set. This leads to longer/harder to read error messages, especialy if the name of T is long (e.g. Foo<TestingFooerTrait> instead of Foo in argument conversion errors assuming __type is set to Foo)

Due to backward compatibility reasons and cases where this behaviour is not desired however, this should probably be a flag (either in LuaOptions or in UserData itself)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions