
20 Cal.2d 640 (1942)
MONROE L. MOSS, Appellant,
v.
EMILY M. MOSS, Respondent.
S. F. No. 16188. 
Supreme Court of California. In Bank.  
Aug. 3, 1942.
 Livingston & Livingston and Allen H. Barr for Appellant.
 Manson & Allan, Dudley F. Miller and Letitia R. Farber for Respondent.
 GIBSON, C.J.
 Plaintiff brought this action against his former wife for declaratory relief seeking a determination of his obligations under a property settlement agreement executed in 1928 and a modification thereof executed in 1932. The trial court sustained a demurrer to the complaint without leave to amend, and plaintiff appeals from the judgment entered for defendant.
 The following allegations of the complaint must be regarded as true for the purposes of this appeal. Plaintiff and defendant, who were married in 1919, separated from one another on or about December 24, 1927. At that time, plaintiff alleges, it was agreed that defendant would obtain the divorce, and that "in consideration of such divorce and for no other consideration whatsoever, [plaintiff] would enter into a property settlement agreement with defendant to settle and determine their respective property rights and to provide for defendant's support and maintenance until she should remarry." In conformity with this plan, plaintiff and defendant entered into a separation agreement on March 21, 1928, by which, among other things, plaintiff was to pay to the defendant, Emily M. Moss, the sum of $250 per month during the period of her natural life until her remarriage. Thereafter the defendant wife brought an action for divorce, which plaintiff did not contest. An interlocutory judgment was entered on March 31, 1928, and a final judgment was entered on April 18, 1929. No reference was made to the separation agreement in either of the decrees. The modification of the agreement, made in October, 1932, reduced the monthly payments to $200 per month, but it provided that plaintiff's failure to meet any payment would result in a reinstatement of the original sum of $250 per month. Plaintiff alleged that an actual controversy exists between the parties as to his duties under these agreements. A judgment was sought declaring *642 that the contract and modification thereof are void as against public policy and that he has no obligations or duties thereunder.
 [1] The law is settled that where a property settlement between husband and wife is entered into, conditioned upon an agreement to procure a divorce, the contract is against public policy and is invalid for that reason. (Brown v. Brown, 8 Cal.App.2d 364 [47 P.2d 352]; Newman v. Freitas, 129 Cal. 283 [61 P. 907, 50 L.R.A. 548]; Pereira v. Pereira, 156 Cal. 1 [103 P. 488, 134 Am.St.Rep. 107, 23 L.R.A. (N. S.) 880]; See Restatement, Contracts,  586; 6 Williston, Contracts (rev. ed. 1938),  1743, p. 4933.) Under the allegations of the complaint, which are admitted by defendant's demurrer, the sole consideration for the property settlement here involved was an agreement by the defendant wife to procure a divorce. Since the case arises on demurrer, there is no need upon this appeal to consider whether it ultimately might be found that this agreement could be sustained because not actually promotive of divorce but merely incidental thereto. (Cf. Howard v. Adams, 16 Cal.2d 253 [105 P.2d 971, 130 A.L.R. 1003]; Cookinham v. Cookinham, 219 Cal. 723 [28 P.2d 1045]; Queen v. Queen, 44 Cal.App.2d 475, 483 [112 P.2d 755].) Assuming the property settlement agreement to be invalid, the question is whether plaintiff is entitled to a declaration to that effect.
 [2] We are of the opinion that the allegations are sufficient to state a cause of action under the statute and would have justified the trial court in granting a declaratory judgment. (Code Civ. Proc.,  1060; Pacific States Corp. v. Pan-American Bank, 213 Cal. 58, 63 [1 P.2d 4, 981]; Oldham v. Moodie, 94 Cal.App. 88, 89 [270 P. 688]; Andrews v. W. K. Company, 35 Cal.App.2d 41, 45 [94 P.2d 605].) Declaratory relief, however, may be refused in the discretion of the trial court if it appears that the determination is not necessary or proper at the time and under all the circumstances. (Code Civ. Proc.,  1061.) Where facts appear from the face of the complaint which would justify a trial court in concluding that its determination is not necessary or proper, it has been held that the court may sustain a general demurrer to the complaint for declaratory relief. (Communist Party v. Peek, ante, p. 536 [__________ P.2d __________]; City of Alturas v. Gloster, 16 Cal.2d 46 [104 P.2d 810]; Stenzel v. Kronick, 102 Cal.App. 507 [283 P. 93]; Rapaport v. Forer, 20 Cal.App.2d 271 [66 P.2d 1242]; A. Hamburger & Sons v. *643 Kice, 129 Cal.App. 68 [18 P.2d 115].) Plaintiff urges that the discretion of the court in refusing to grant the relief sought should not be exercised in ruling upon a general demurrer, but only after sufficient facts are before the court to justify the entry of such a judgment on the merits. (See Miller v. Currie, 208 Wis. 199 [242 N.W. 570]; Bruckman v. Bruckman Co., 60 Ohio App. 361 [21 N.E. (2d) 481]; Anderson, Declaratory Judgments (1940), p. 271.) It is true that an order sustaining a general demurrer to a complaint for declaratory relief does not indicate to the appellate court whether the trial court concluded that relief was inappropriate or that there was failure to state a cause of action. While it might be better practice for the trial court to overrule the demurrer and exercise its discretion in denying declaratory relief by some other procedure, as, for example, upon a motion to dismiss (cf. Cutting v. Bryan, 206 Cal. 254 [274 P. 326]), the fact that it did so in ruling upon the general demurrer cannot be held reversible error in view of the decided cases in this state.
 [3] Since we have held that this complaint was sufficient to authorize a declaration of plaintiff's obligations under the contract, we must now consider whether the trial court abused its discretion in denying declaratory relief under the circumstances here presented. Plaintiff urges that the trial court abused its discretion and that there is no basis upon which its determination can be sustained. It is not necessary for us to consider each of the various grounds advanced by defendant in support of the trial court's conclusion. The fact that plaintiff was a party to the unlawful bargain of equal fault with defendant and is therefore in pari delicto, is a consideration which could properly have been considered by the trial court as a sufficient reason for declining to grant declaratory relief. It is contended by plaintiff that such an action is not strictly an action in equity and, therefore, that the doctrine of in pari delicto should not be applied. It is also contended that the defense of in pari delicto has no application where the plaintiff is merely seeking to relieve himself from the executory portion of an illegal agreement, citing Wassermann v. Sloss, 117 Cal. 425 [49 P. 566, 59 Am.St.Rep. 209, 38 L.R.A. 176], and National Stone Tile Corp. v. Voorheis, 93 Cal.App. 738 [270 P. 286]. It is true that declaratory relief is not strictly legal or equitable, but is suis generis in nature (Gore v. Bingaman, ante, pp. 118, 120 [124 P. *644 (2d) 17]; see Borchard, Declaratory Judgments (2d ed. 1941), pp. 238, 248, 399, 439) and that in pari delicto is not ordinarily applied to the executory portions of an illegal agreement. (Cases supra, and see 3 Pomeroy, Equity Jurisprudence (5th ed. 1941) sec. 940, pp. 728-733.) Assuming, however, as contended by plaintiff, that the doctrine of in pari delicto should not be treated as an absolute bar to this action, it is nevertheless an element which the trial court in its discretion could consider in deciding whether or not to grant declaratory relief under the circumstances presented here. (Cf. Borchard, supra, pp. 239-240, 304-305.) It cannot be said, therefore, that the trial court abused its discretion, and we find no error in its conclusion that declaratory relief was not proper under the facts of this case.
 [4] It is contended that the complaint also alleges facts stating a cause of action for cancellation of the agreement. The defendant, however, specified the statute of limitations as one of the grounds of her demurrer, and although there is no section of the code that expressly limits the time within which an action must be brought for cancellation of an instrument because of its illegality, section 343 of the Code of Civil Procedure provides that "An action for relief not hereinbefore provided for must be commenced within four years after the cause of action shall have accrued." It appears from the face of the complaint that this action was brought more than ten years after the separation agreement was made and more than five years after the modification thereof; thus it is obvious that if section 343 is applicable to an action for cancellation for illegality, plaintiff is precluded thereby.
 It is well settled in California that, as stated in Piller v. Southern Pac. R. R. Co., 52 Cal. 42, 44, "the four years' limitation of section 343 applies to all suits in equity not strictly of concurrent cognizance in law and equity." (See, also, Sherman v. S. K. D. Oil Co., 185 Cal. 534, 545 [197 P. 799].) This section has been considered applicable, for example, to actions based upon express and constructive trusts (Scott v. Symons, 191 Cal. 441, 456 [216 P. 604]; Wrightson v. Dougherty, 5 Cal.2d 257, 264 [54 P.2d 13]), to actions for an accounting (McArthur v. Blaisdell, 159 Cal. 604 [115 P. 52]; West v. Russell, 74 Cal. 544 [16 P. 392]), to an action in the nature of a creditor's bill against holders of watered stock (Sherman v. S. K. D. Oil Co., supra), to an action to set aside deeds made under undue influence *645 (Trubody v. Trubody, 137 Cal. 172, 174 [69 P. 968]), and to a proceeding under section 708 of the Code of Civil Procedure to set aside a satisfaction and revive a judgment after an execution and sale made thereunder had been found void. (Merguire v. O'Donnell, 139 Cal. 6, 9 [72 P. 337, 96 Am.St.Rep. 91].) In Hynes v. M. J. & M. M. Consolidated, 168 Cal. 651 [144 P. 144], it was held that the section barred a suit in equity to vacate a judgment for lack of due service of process. It has been held, also, that section 343 bars an action to recover money illegally paid by a city official brought on the theory that the defendant was an involuntary trustee. (City of Petaluma v. Hickey, 90 Cal.App. 616 [266 P. 613].) This court has indicated, although without expressly so stating, that a lapse of time beyond the period of the statute would prevent relief in an action to cancel void bonds. (Wenban Estate, Inc. v. Hewlett, 193 Cal. 675, 705-706 [227 P. 723]; Sechrist v. Rialto Irrigation Dist., 129 Cal. 640, 645- 646 [62 P. 261].) Further, as the court said in Bogart v. George K. Porter Co., 193 Cal. 197, 201 [223 P. 959, 31 A.L.R. 1045]: "The legislature has ... specified the limitations applicable to a wide variety of actions, and then to rebut the possible inference that actions not therein specifically described are to be regarded as exempt from limitations, it has specified a four-year limitation upon 'an action for relief not hereinabove provided for' ( 343); and where it has intended that an action shall be exempt from limitations it has said so in clear and unmistakable language. (Code Civ. Proc.,  348; Civ. Code,  309.)" Although plaintiff contends that laches and lapse of time cannot be defenses in an action to cancel an instrument void because contrary to public policy, citing Colby v. Title Ins. & Trust Co., 160 Cal. 632 [117 P. 913, Ann. Cas. 1913A, 515, 35 L.R.A. (N. S.) 813], the equitable factors considered in that decision may not be used as a means of avoiding the express mandate of the statute of limitations. We must hold, therefore, that if plaintiff had a cause of action for cancellation, it is now barred by section 343 of the Code of Civil Procedure.
 The judgment is affirmed.
 Shenk, J., Curtis, J., Edmonds, J., Carter, J., Traynor, J., concurred.
