Skip to content

Override mapping from generated function name to attribute#8958

Merged
Arcticae merged 1 commit intomainfrom
fix/generate-entrypoint-fn-name-mapping
Dec 9, 2025
Merged

Override mapping from generated function name to attribute#8958
Arcticae merged 1 commit intomainfrom
fix/generate-entrypoint-fn-name-mapping

Conversation

@Arcticae
Copy link
Collaborator

@Arcticae Arcticae commented Dec 8, 2025

Semantically it's not the same function, therefore it should not be mapped back to the original function's name

@reviewable-StarkWare
Copy link

This change is Reviewable

@Arcticae Arcticae marked this pull request as ready for review December 8, 2025 10:18
@Arcticae Arcticae requested a review from orizi December 8, 2025 10:18
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @Arcticae)


crates/cairo-lang-starknet/src/plugin/entry_point.rs line 210 at r1 (raw file):

                .mapped(db, &trigger_attribute),
            );
        }

Suggestion:

    let function_name = RewriteNode::from_ast_trimmed(&name_node);
    let wrapper_function_name = format!("{WRAPPER_PREFIX}{wrapper_identifier}");
    match generate_entry_point_wrapper(
        db,
        item_function,
        wrapped_function_path,
        RewriteNode::text(&wrapper_function_name),
        generic_params,
        unsafe_new_contract_state_prefix,
    ) {
        Ok(generated_function) => {
            data.generated_wrapper_functions
                .push(generated_function.mapped(db, &trigger_attribute));
            data.generated_wrapper_functions.push(RewriteNode::text("\n"));
            let generated = match entry_point_kind {
                EntryPointKind::Constructor => &mut data.constructor_functions,
                EntryPointKind::L1Handler => {
                    validate_l1_handler_second_parameter(db, &params, diagnostics);
                    &mut data.l1_handler_functions
                }
                EntryPointKind::External => &mut data.external_functions,
            };
            generated.push(
                RewriteNode::Text(format!(
                    "\n    pub use super::{wrapper_function_name} as {function_name};"
                ))
                .mapped(db, &trigger_attribute),
            );
        }

@Arcticae Arcticae force-pushed the fix/generate-entrypoint-fn-name-mapping branch from 16f86f9 to 09e4efe Compare December 8, 2025 11:55
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @Arcticae)


crates/cairo-lang-starknet/src/plugin/entry_point.rs line 175 at r2 (raw file):

    }

    let wrapper_function_name = &format!("{WRAPPER_PREFIX}{}", wrapper_identifier);

Suggestion:

    let wrapper_function_name = &format!("{WRAPPER_PREFIX}{wrapper_identifier}");

crates/cairo-lang-starknet/src/plugin/entry_point.rs line 196 at r2 (raw file):

                EntryPointKind::External => &mut data.external_functions,
            };
            let function_name = name_node.as_syntax_node().get_text_without_trivia(db).to_string(db);

Suggestion:

            let function_name = name_node.text(db).long(db);

@Arcticae Arcticae force-pushed the fix/generate-entrypoint-fn-name-mapping branch from 09e4efe to 865d23e Compare December 8, 2025 12:37
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@orizi reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae)

@Arcticae Arcticae force-pushed the fix/generate-entrypoint-fn-name-mapping branch from 865d23e to 91ec4ec Compare December 8, 2025 12:55
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae)

@Arcticae Arcticae force-pushed the fix/generate-entrypoint-fn-name-mapping branch from 91ec4ec to ffe1b3d Compare December 8, 2025 15:12
@Arcticae Arcticae force-pushed the fix/generate-entrypoint-fn-name-mapping branch from ffe1b3d to 7e6ef4b Compare December 8, 2025 15:13
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@orizi reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae)

@Arcticae Arcticae added this pull request to the merge queue Dec 9, 2025
Merged via the queue into main with commit abec09b Dec 9, 2025
54 checks passed
@orizi orizi deleted the fix/generate-entrypoint-fn-name-mapping branch December 11, 2025 08:23
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.

3 participants