dictu-lang / Dictu

Dictu is a high-level dynamically typed, multi-paradigm, interpreted programming language.
https://dictu-lang.com
MIT License
267 stars 53 forks source link

[BUG] - Sometimes methods with annotations aren't processed correctly #590

Closed briandowns closed 1 year ago

briandowns commented 1 year ago

Is there an existing issue for this?

Current Behavior

I haven't been able to determine a cause yet but on Linux systems, occasionally a method with annotations will complete parsing incorrectly. The __annotatedMethod placeholder isn't always replaced with the method name.

Expected Behavior

No response

Steps To Reproduce

No response

Anything else?

No response

Jason2605 commented 1 year ago

This is interesting, do you have an example source file I can try?

briandowns commented 1 year ago

I have a very specific code base that this was observed in but I'll get something together to demonstrate. Apologies. I should have included an example.

Jason2605 commented 1 year ago

It's all good! Yeah, if you can piece together something where you can reproduce that would be incredibly helpful, thank you

briandowns commented 1 year ago

The relevant code is the last method in this class.

@Controller("/api/v1/releases")
class Releases {
    private dataStore;

    init(dataStore) {
        this.dataStore = dataStore;
    }

    @Post
    new(request) {
        if (request.query.exists("id")) {
            const key = request.query.get("id");
            return {
                key: this.dataStore.get(key)
            };
        }

        return [this.dataStore];
    }

    @Get
    @Cache(10)
    retrieve(request) {
        if (request.query.exists("id")) {
            const key = request.query.get("id");
            return {
                key: this.dataStore.get(key)
            };
        }

        return [this.dataStore];
    }

    @Get
    @Path("/last")
    last(request) {
        const keys = this.dataStore.keys();
        const idx = this.dataStore.len()-1;
        const lastKey = keys[idx];

        return JsonResponse({lastKey: this.dataStore.get(lastKey)});
    }
}

print(Releases.methodAnnotations);

Results:

{"new": {"Post": nil}, "retrieve": {"Cache": 10, "Get": nil}, "__annotatedMethodName": {"Path": "/last", "Get": nil}}
Jason2605 commented 1 year ago

I think it may actually be to do with dictDelete. Removing that call seems to have all the methods along with the placeholder

Jason2605 commented 1 year ago

Okay yeah, it's the dictSet. The robinhood hashing is moving entries about so entry->key now points at something else. Should be resolvable