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

if_block_creators[current_block_type_index] is not a function #1580

Closed
MNITD opened this issue Jul 8, 2018 · 3 comments
Closed

if_block_creators[current_block_type_index] is not a function #1580

MNITD opened this issue Jul 8, 2018 · 3 comments
Labels

Comments

@MNITD
Copy link

MNITD commented Jul 8, 2018

I was trying to create component with several if-else statements, that depends on component data variable.

First statement block should add one of nested components, second statement block should add some button tags.

I got an error if_block_creators[current_block_type_index] is not a function

https://svelte.technology/repl?version=2.9.1&gist=6e02554521c9ea732c3b7e8a883ef664

@Conduitry
Copy link
Member

(Things are a bit more confusing in the REPL at the moment than the should be because of this issue. For now, it's best to look at this by downloading the .zip and running it locally.)

The issue here seems to be that the two select_block_type functions are getting the same name - one of them isn't a select_block_type_1. I'm not sure why this is the case. This causes this particular exception here because the second one (for the second if with the <button>s) returns the block itself, while the first one (for the if with the <NestedComponent>s) returns a 0 or a 1 because of the separate handling for (potential) outros in sub-components. The second select_block_type overwrites the first, and we end up trying to use the block object as an index into an array.

@Conduitry
Copy link
Member

Didn't mean to autoclose this until the fix is actually released.

@Conduitry Conduitry reopened this Jul 8, 2018
@Conduitry
Copy link
Member

Fixed in 2.9.2. Thanks! The REPL issue I mentioned has also been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants