Skip to content

fix: 🐛 fixed super fixing #425

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

Merged
merged 2 commits into from
Nov 14, 2024
Merged

Conversation

KANAjetzt
Copy link
Member

With the changes from #420, we need to start the search for closing_paren_index at func_def_end - 1.

But this needs a deeper look. based on my debugging, it seems there’s more wrong with how we’re processing that part.

Some print debugging

  text on func_def_end: ) ->
  method_name: _ready
  closing_paren_index: -1
  func_def_end: 83
  ---
  extends Portal
  
  
  @export var label_level_name_override := "New Game"
  
  
  func _ready() -> void:
      super()
      label_level_name.text = label_level_name_override
  
  
  func _on_hit_detector_body_entered(body: Node3D) -> void:
      super(body)
      Global.reset_game()
  
  No matching closing parenthesis
  text on func_def_end: body
  method_name: _on_hit_detector_body_entered
  closing_paren_index: -1
  func_def_end: 210
  ---
  extends Portal
  
  
  @export var label_level_name_override := "New Game"
  
  
  func vanilla_4007268940__ready() -> void:
      super()
      label_level_name.text = label_level_name_override
  
  
  func _on_hit_detector_body_entered(body: Node3D) -> void:
      super(body)
      Global.reset_game()
  
  No matching closing parenthesis
  • I think text on func_def_end should always start with ). It looks like the result is shifted for the second method, and if this pattern continues, things will start to break again.

For now, this should be enough to keep things moving.

with the changes from GodotModding#420 we have to start the search for the colsing_paren_index at `func_def_end - 1`
@KANAjetzt KANAjetzt added bug Something isn't working 4.x labels Nov 13, 2024
@KANAjetzt KANAjetzt added this to the 4.x - 7.0.0 milestone Nov 13, 2024
@KANAjetzt KANAjetzt requested a review from Qubus0 November 13, 2024 22:14
@KANAjetzt KANAjetzt self-assigned this Nov 13, 2024
Copy link
Collaborator

@Qubus0 Qubus0 left a comment

Choose a reason for hiding this comment

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

match_func_with_whitespace actually matches until including the first opening ( of a function, func _ready( for example. the following characters are "shifted" because they don't matter, the end of the full function declaration can only be after get_closing_paren_index finds the correct closing index.
since match_func_with_whitespace always includes the (, we actually always have to subtract 1, since get_closing_paren_index starts from the exact index where that ( is, not one after it.
this code is actually more stable now, the previous version would have caused more issues eventually.
we should document these better though, and better naming is also in order

@KANAjetzt
Copy link
Member Author

Oh right - in the morning everything seems clearer 😄
So I change it in get_closing_paren_index() then.

static func get_closing_paren_index(opening_paren_index: int, text: String) -> int:
	# Use a stack counter to match parentheses
	var stack := 0
	var closing_paren_index := opening_paren_index - 1 # Shift the index back by one to start before the opening parentheses.
        [...]

@Qubus0
Copy link
Collaborator

Qubus0 commented Nov 14, 2024

nono, where it is is completely correct. that is a thing specific to using get_closing_paren_index right after match_func_with_whitespace. though that's the only way we use it currently since we do -1 in both fix_method_super and get_function_parameters

@KANAjetzt
Copy link
Member Author

ok got it now 😄 then I add the comment where we call get_closing_paren_index() in fix_method_super() and get_function_parameters()

@KANAjetzt KANAjetzt added this pull request to the merge queue Nov 14, 2024
Merged via the queue into GodotModding:4.x with commit 3c3bede Nov 14, 2024
1 check passed
@KANAjetzt KANAjetzt deleted the fix_super_fixing branch November 14, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants