Allow merging target specific variable with double-colon rule
diff --git a/exec.go b/exec.go
index 5d509e7..a6821f4 100644
--- a/exec.go
+++ b/exec.go
@@ -388,7 +388,7 @@
 	return true
 }
 
-func mergeRules(oldRule, rule *Rule) *Rule {
+func mergeRules(oldRule, rule *Rule, output string, isSuffixRule bool) *Rule {
 	if oldRule.vars != nil || rule.vars != nil {
 		oldRule.isDoubleColon = rule.isDoubleColon
 		switch {
@@ -402,6 +402,14 @@
 		}
 	}
 
+	if oldRule.isDoubleColon != rule.isDoubleColon {
+		Error(rule.filename, rule.lineno, "*** target file %q has both : and :: entries.", output)
+	}
+	if len(oldRule.cmds) > 0 && len(rule.cmds) > 0 && !isSuffixRule && !rule.isDoubleColon {
+		Warn(rule.filename, rule.cmdLineno, "overriding commands for target %q", output)
+		Warn(oldRule.filename, oldRule.cmdLineno, "ignoring old commands for target %q", output)
+	}
+
 	r := &Rule{}
 	*r = *rule
 	if rule.isDoubleColon {
@@ -434,14 +442,7 @@
 		isSuffixRule := ex.populateSuffixRule(rule, output)
 
 		if oldRule, present := ex.rules[output]; present {
-			if oldRule.isDoubleColon != rule.isDoubleColon {
-				Error(rule.filename, rule.lineno, "*** target file %q has both : and :: entries.", output)
-			}
-			if len(oldRule.cmds) > 0 && len(rule.cmds) > 0 && !isSuffixRule && !rule.isDoubleColon {
-				Warn(rule.filename, rule.cmdLineno, "overriding commands for target %q", output)
-				Warn(oldRule.filename, oldRule.cmdLineno, "ignoring old commands for target %q", output)
-			}
-			r := mergeRules(oldRule, rule)
+			r := mergeRules(oldRule, rule, output, isSuffixRule)
 			ex.rules[output] = r
 		} else {
 			ex.rules[output] = rule
diff --git a/testcase/double_colon_rule.mk b/testcase/double_colon_rule.mk
index c39dc20..d28448d 100644
--- a/testcase/double_colon_rule.mk
+++ b/testcase/double_colon_rule.mk
@@ -2,3 +2,8 @@
 	echo FOO
 test::
 	echo BAR
+
+test:: A=B
+
+# Merge a double colon rule with target specific variable is OK.
+test: A=B