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

fix: ensure free function are not impacted by the injection of world and self #1733

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ output.txt
crates/benches/bench_results.txt
**/generated
.vscode
bindings
9 changes: 6 additions & 3 deletions crates/dojo-lang/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ impl DojoContract {
has_storage = true;
return system.merge_storage(db, struct_ast.clone());
}
} else if let ast::ModuleItem::FreeFunction(fn_ast) = el {
return system.rewrite_function(db, fn_ast.clone());
} else if let ast::ModuleItem::Impl(impl_ast) = el {
return system.rewrite_impl(db, impl_ast.clone());
// If an implementation is not targetting the ContractState,
// the auto injection of self and world is not applied.
let trait_path = impl_ast.trait_path(db).node.get_text(db);
if trait_path.contains("<ContractState>") {
return system.rewrite_impl(db, impl_ast.clone());
}
}

vec![RewriteNode::Copied(el.as_syntax_node())]
Expand Down
Loading
Loading