dstep icon indicating copy to clipboard operation
dstep copied to clipboard

Built-in properties are not handled correctly

Open jacob-carlborg opened this issue 5 years ago • 3 comments

Symbols with the same name as the built-in properties [1] are not handled correctly, i.e. they should have a trailing underscore like real keywords. Examples are alignof and mangleof. Some properties applies to all types while some other properties are specific to a subset of types.

[1] https://dlang.org/spec/property.html

jacob-carlborg avatar Oct 12 '18 08:10 jacob-carlborg

Could you provide an example/example translation?

ciechowoj avatar Dec 31 '18 14:12 ciechowoj

The following C code:

struct Foo
{
    int mangleof;
};

Is translated to this D code:

extern (C):

struct Foo
{
    int mangleof;
}

Compiling the above D code will result in the following error:

Error: variable `main.Foo.mangleof` `.mangleof` property cannot be redefined

jacob-carlborg avatar Dec 31 '18 14:12 jacob-carlborg

Assuming that the above link is correct, it would be something like this:

  • For classes, structs and enums: init, sizeof, alignof, mangleof, stringof
  • For enums: min, max
  • For classes: classinfo

jacob-carlborg avatar Dec 31 '18 14:12 jacob-carlborg