Skip to content

Conversation

llogick
Copy link
Contributor

@llogick llogick commented Aug 22, 2022

note:
adds an edge case in analysis.makeScopeInternal to prevent
leaking memory when adding duplicate container fields w/ name "other"
but there really should be a check for duplicates

edit:

        if (container_field) |_| {
            if (!std.mem.eql(u8, name, "_")) {
                var doc = if (try getDocComments(allocator, tree, decl, .Markdown)) |docs|
                        types.MarkupContent{ .kind = .Markdown, .value = docs }
                    else
                        null;
                var gop_res = try context.enums.getOrPut(allocator, .{
                    .label = name,
                    .kind = .Constant,
                    .insertText = name,
                    .insertTextFormat = .PlainText,
                    .documentation = doc
                });
                if (gop_res.found_existing) {
                    if (doc) |d| allocator.free(d.value);
                }
            }
        }

adds an edge case in analysis.makeScopeInternal to prevent
leaking memory when adding duplicate container fields w/ name "other"
@leecannon
Copy link
Member

Thanks for this!

@leecannon leecannon merged commit 7c245f7 into zigtools:master Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants