Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too strict cannot find name for type invalid or dynamic #1383

Open
TwitchBronBron opened this issue Dec 23, 2024 · 2 comments
Open

Too strict cannot find name for type invalid or dynamic #1383

TwitchBronBron opened this issue Dec 23, 2024 · 2 comments
Assignees
Milestone

Comments

@TwitchBronBron
Copy link
Member

TwitchBronBron commented Dec 23, 2024

This should not be an error, because the variable is dynamic.

Image

Discovered in the latest commits in v1 on Dec 23, 2024

@markwpearce
Copy link
Collaborator

markwpearce commented Jan 1, 2025

hmm... I can't reproduce this with a test.

This passes in current release-1.0.0 branch:

it.only('allows member access of union with invalid', () => {
    program.setFile('source/main.bs', `
        sub test(channels)
            channel = invalid
            for each channel in channels
                if channel.id = 123
                    print "ok"
                end if
            end for
        end sub
    `);

    program.validate();
    expectZeroDiagnostics(program);
});

@TwitchBronBron
Copy link
Member Author

Here's a test that fails with the issue. Mine was failing for object, but I added another union for roAssociativeArray to ensure that pattern works as well:

it.only('allows member access of union with invalid', () => {
    program.setFile('source/main.bs', `
        sub test()
            channel = invalid
            if true
                channel = {
                    height: 123
                }
            end if
            if true
                channel = createChannel({
                    height: 123
                })
            end if

            height = 0
            if channel <> invalid then
                height += channel.height
            end if
        end sub

        function createChannel(config) as object
            return config
        end function
    `);

    program.validate();
    expectZeroDiagnostics(program);
});

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

No branches or pull requests

2 participants