Browse Source

allow `(get,default)` property access combination (closes #6195, closes #8825)

Aleksandr Kuzmenko 5 years ago
parent
commit
6818ac2af5
2 changed files with 15 additions and 1 deletions
  1. 1 1
      src/typing/typeloadFields.ml
  2. 14 0
      tests/unit/src/unit/issues/Issue6195.hx

+ 1 - 1
src/typing/typeloadFields.ml

@@ -1325,7 +1325,7 @@ let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =
 			display_error ctx (name ^ ": Custom property accessor is no longer supported, please use `set`") pset;
 			AccCall
 	) in
-	if (set = AccNormal && get = AccCall) || (set = AccNever && get = AccNever)  then error (name ^ ": Unsupported property combination") p;
+	if (set = AccNever && get = AccNever)  then error (name ^ ": Unsupported property combination") p;
 	let cf = {
 		(mk_field name ~public:(is_public (ctx,cctx) f.cff_access None) ret f.cff_pos (pos f.cff_name)) with
 		cf_doc = f.cff_doc;

+ 14 - 0
tests/unit/src/unit/issues/Issue6195.hx

@@ -0,0 +1,14 @@
+package unit.issues;
+
+class Issue6195 extends unit.Test {
+	var field(get,default):Int = 1;
+	function get_field():Int {
+		return field + 1;
+	}
+
+	function test() {
+		eq(2, field);
+		field = 10;
+		eq(11, field);
+	}
+}