Bläddra i källkod

make the second argument optional in FKNamed(name, inlined) (closes #8719)

Aleksandr Kuzmenko 6 år sedan
förälder
incheckning
47e53e407c
3 ändrade filer med 6 tillägg och 4 borttagningar
  1. 3 1
      src/macro/macroApi.ml
  2. 1 1
      std/haxe/macro/Expr.hx
  3. 2 2
      tests/misc/projects/issue5002/Main2.hx

+ 3 - 1
src/macro/macroApi.ml

@@ -726,7 +726,9 @@ and decode_display_kind v = match (decode_enum v) with
 
 
 and decode_function_kind kind = if kind = vnull then FKAnonymous else match decode_enum kind with
 and decode_function_kind kind = if kind = vnull then FKAnonymous else match decode_enum kind with
 	| 0, [] -> FKAnonymous
 	| 0, [] -> FKAnonymous
-	| 1, [name;inline] -> FKNamed ((decode_string name,Globals.null_pos), decode_bool inline)
+	| 1, [name;inline] ->
+		let inline = if inline = vnull then false else decode_bool inline in
+		FKNamed ((decode_string name,Globals.null_pos), inline)
 	| 2, [] -> FKArrow
 	| 2, [] -> FKArrow
 	| _ -> raise Invalid_expr
 	| _ -> raise Invalid_expr
 
 

+ 1 - 1
std/haxe/macro/Expr.hx

@@ -393,7 +393,7 @@ enum FunctionKind {
 	/**
 	/**
 		Named function
 		Named function
 	**/
 	**/
-	FNamed(name:String, inlined:Bool);
+	FNamed(name:String, ?inlined:Bool);
 	/**
 	/**
 		Arrow function
 		Arrow function
 	**/
 	**/

+ 2 - 2
tests/misc/projects/issue5002/Main2.hx

@@ -31,7 +31,7 @@ class Main2 {
 
 
 	static macro function invalidFunctionName() {
 	static macro function invalidFunctionName() {
 		return {
 		return {
-			expr: EFunction(FNamed("0_function", false), {
+			expr: EFunction(FNamed("0_function"), {
 				args: [],
 				args: [],
 				ret: macro:Void,
 				ret: macro:Void,
 				expr: macro {}
 				expr: macro {}
@@ -42,7 +42,7 @@ class Main2 {
 
 
 	static macro function invalidFunctionArgumentName() {
 	static macro function invalidFunctionArgumentName() {
 		return {
 		return {
-			expr: EFunction(FNamed("foo", false), {
+			expr: EFunction(FNamed("foo"), {
 				args: [
 				args: [
 					{
 					{
 						name: "0_argument",
 						name: "0_argument",