theos/logos

Dynamically looking-up classes beside bracketed math causes compiling error

candoizo opened this issue · 3 comments

example : self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y + 1 - (1 * 2), [%c(UIScreen) mainScreen].bounds.size.width, self.frame.size.height);

What are the steps to reproduce this issue?

  1. Try to use brackets in calculations next to dynamically looked-up classes
  2. Receive error when compiling

What happens?

Compiler returns expression error

What were you expecting to happen?

Compiles with no problems

Any logs, error output, etc?

==> Compiling Tweak.xm (armv7)…

Tweak.xm:11:85: error: expected expression self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y + 1 - (1 * 2), [%c(UIScreen) mainScreen].b...
^
Tweak.xm:11:88: error: unexpected interface name 'UIScreen': expected expression self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y + 1 - (1 * 2), [%c(UIScreen) mainScreen].b...

Any other comments?

Compiles fine without the brackets around (1 * 2), but obviously will not return the value needed.

Changing the positioning of the bracketed math does not overcome the error

Does not work with objc_getClass either

Adding an interface for the class will avoid the issue.

Compiling using linux toolchain, 9.2 sdk, most recent theos pull

kirb commented

Can’t repro with the latest Logos, can you check if this still happens for you? Try to create a minimal test case — a Logos file with as little as you need to trigger the bug. Run $THEOS/bin/logos.pl mytest.x and make sure you see _logos_static_class_lookup$UIScreen() being defined and used in the appropriate place with no syntax errors.

kirb commented

Perfect! There are also fixes from #246 that I’ve been meaning to merge that would probably help reduce these errors.