dlang-community / Pegged

A Parsing Expression Grammar (PEG) module, using the D programming language.
533 stars 66 forks source link

Bump new version #322

Closed iK4tsu closed 1 year ago

iK4tsu commented 1 year ago

@ljmf00-wekaio fixed dip1000 issues a while ago but this isn't tagged yet; could you release a new version with these fixes?

ljmf00-wekaio commented 1 year ago

I need to finish something I promised but end up getting at the bottom of my task list.

veelo commented 1 year ago

For context, this is it: https://github.com/PhilippeSigaud/Pegged/pull/314#issuecomment-1315512690.

To be fair, that change is likely necessary only when dmd#14236 gets merged, and that PR has currently stalled (@dkorpel). So we could decide to tag Pegged now if we remember to make the change before a new DMD release makes that necessary.

It seems a rather trivial change, though, so @iK4tsu if you want to have a go at it, maybe @ljmf00-wekaio can review it and we can release without pending TODO's.

ljmf00-wekaio commented 1 year ago

Yes, if you can @iK4tsu, I appreciate. It's basically implement something like:

/**
 * Assume non scope variable
 *
 * This function casts away scope attribute from the given parameter.
 *
 * Params:
 *     arg = The scope variable to cast scope away
 *
 * Returns: the variable `arg` as is, but without scope attribute.
 *
 * Note: This breaks the language type system.
 */
@nogc
auto ref assumeNonScope(T)(auto ref scope T arg)
{
    return *cast(T*)cast(void*)&arg;
}

And use in the dip1000 hacks I added. Also, worth mentioning @dkorpel that the hack with size_t doesn't work with all types, hence I use void*.

veelo commented 1 year ago

* Note: This breaks the language type system.

Could you help me understand why it is necessary to break the language type system? Is it because the compiler gets it wrong (https://github.com/PhilippeSigaud/Pegged/pull/314#issuecomment-1255311759)?

ljmf00-wekaio commented 1 year ago

Yes, cast(void*) is pretty much breaking the type system, in terms of changing type qualifiers or lifetime attributes. This shouldn't be required if the compiler could construct a DAG of the lifetimes and do these checks properly, but you can read more about the issue in the referenced bugzilla tickets on the PR you just mentioned.

iK4tsu commented 1 year ago

Yes, if you can @iK4tsu, I appreciate. It's basically implement something like:

/**
 * Assume non scope variable
 *
 * This function casts away scope attribute from the given parameter.
 *
 * Params:
 *     arg = The scope variable to cast scope away
 *
 * Returns: the variable `arg` as is, but without scope attribute.
 *
 * Note: This breaks the language type system.
 */
@nogc
auto ref assumeNonScope(T)(auto ref scope T arg)
{
    return *cast(T*)cast(void*)&arg;
}

And use in the dip1000 hacks I added. Also, worth mentioning @dkorpel that the hack with size_t doesn't work with all types, hence I use void*.

casting to void* does not cast away scope

veelo commented 1 year ago

New release: v0.4.7.