Coding 2023-05-17

Tags:
By Max Woerner Chase

Okay, let's think about the saltate plugin some more. There are a few transformations and checks I want to do. Currently, on line 131, it expects to receive a typ that is a TypeType, an AnyType, or just wrong. This needs to be extended to handling a UnionType. For a UnionType, we basically need to handle any of the items potentially being Any or otherwise not TypeType.

Something like:

return_permissive = False
for item in magic_func(...):
    item = get_proper_type(item)
    if isinstance(item, TypeType):
        pass
    elif isinstance(item, AnyType):
        return_permissive = True
    else:
        ctx.api.fail(...)
        return_permissive = True
        break
if return_permissive:
    return permissive_signature

I'm not feeling great about the exact structure there, but anyway. Line 136 converts the TypeType or the UnionType of TypeTypes into either the underlying type, or the union of the underlying types. I can get that by augmenting the above lines.

return_permissive = False
items = []
for item in magic_func(...):
    item = get_proper_type(item)
    if isinstance(item, TypeType):
        items.append(item.item)
    elif isinstance(item, AnyType):
        return_permissive = True
    else:
        ctx.api.fail(...)
        return_permissive = True
        break
if return_permissive:
    return permissive_signature

typ_type = UnionType.make_union(items)

The next code to handle is at 159. I'm not quite sure what has to be done here. There are two angles to take. The actual type comparisons have to reach into the unions, and convert all args to Instance types to Any. For diagnostics, I need to construct a sequence of names, and potentially do extra formatting to it.

I think I understand how all of this needs to be implemented, but I don't want to do it right now. At least I'm pretty sure I know what to do.

And what to do now, is get ready for bed.

Good night.