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

Add MFromMacroInMacro constraint and check it when iterating/matching #11406

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

Simn
Copy link
Member

@Simn Simn commented Nov 22, 2023

For #11403.

class Test {
	static function main() {
		var x = getValues();
		switch x {
			case [1]:
			default:
		}
	}

	public static macro function getValues() {
		return macro [1];
	}
}
 ERROR  (macro) source/Main.hx:4: characters 10-11

 4 |   switch x {
   |          ^
   | Cannot match on expression from macro-in-macro call

    3 |   var x = getValues();
      |           ^^^^^^^^^^^
      | Call was here
class Main {
	static function main() {
		for (v in getValues())
			trace(v);
	}

	public static macro function getValues() {
		getValues();
		return macro [];
	}
}
 ERROR  (macro) source/Main.hx:3: characters 13-24

 3 |   for (v in getValues())
   |             ^^^^^^^^^^^
   | Cannot iterate on expression from macro-in-macro call

 ERROR  source/Main.hx:3: characters 13-24

There are likely still ways to break this and we still need tests, but the situation is a bit better than before. There are also still the errors from the not-macro context because our typer recovers way too much, but that's a more general problem (related to #11395).

@skial skial mentioned this pull request Nov 28, 2023
1 task
# Conflicts:
#	src/context/typecore.ml
#	src/typing/matcher.ml
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.

None yet

1 participant