
387 N.W.2d 298 (1986)
STATE of Iowa, Appellee,
v.
Lewis LUCKETT, a/k/a Lewis Branch, Appellant.
No. 84-1589.
Supreme Court of Iowa.
May 21, 1986.
Charles L. Harrington, Appellate Defender, and John P. Messina, Asst. Appellate Defender, for appellant.
Thomas J. Miller, Atty. Gen., Rebecca L. Claypool, Asst. Atty. Gen., William E. Davis, Co. Atty., and Douglas Wells, Asst. Co. Atty., for appellee.
Considered by REYNOLDSON, C.J., and HARRIS, CARTER, WOLLE, and LAVORATO, JJ.
HARRIS, Justice.
Two questions are presented in this appeal following defendant's conviction of attempted murder. See Iowa Code § 707.11 (1983). We reject defendant's contention that aggravated assault and simple assault should have been submitted as lesser included offenses, but we agree it was error to impose a mandatory sentence.
Evidence of defendant's guilt was overwhelming. The victim, Wade Dawson, had formerly been married to Sandra Arrington who became romantically involved with defendant. A great deal of animosity developed *299 over Dawson's visitation rights to Dawson's and Sandra's child. On the day of the shooting Sandra, defendant, and another man confronted Julie Dawson, the victim's second wife, and made a threat against Dawson. This threat was just one in a long series.
On the evening in question Dawson left home and drove around Davenport looking for his wife Julie. He noticed Sandra's car following him and when he returned home the other car pulled in front of him. Defendant jumped out, approached Dawson's car and fired a shot into the windshield at a range of six or seven feet. Police testimony disclosed that Dawson would have been struck had the bullet passed through his windshield. Defendant was tried before a jury which found him guilty of attempted murder.
I. The trial court refused defendant's request for submission of verdicts for the lesser included offenses of assault and assault with intent to inflict serious injury. The court of appeals affirmed the trial court's refusal and on further review of this assignment we agree.
Pursuant to Iowa rule of criminal procedure 6(3), the trial court must instruct the jury on the charged offense and all lesser included offenses. Rule 21(3) provides that "[i]n all cases, the defendant may be found guilty of any offense the commission of which is necessarily included in that with which the defendant is charged." A defendant may be convicted only of the highest offense which the jury finds established. See Iowa Code § 701.9 (1983); Iowa R.Crim.P. 6(2). We have prescribed a two-part test to determine whether a lesser offense falls under a charged offense:
The legal or element test requires the lesser offense to be composed solely of some but not all of the elements of the greater offenses. Thus the lesser offense is necessarily included in the greater offense if the greater offense cannot be committed without also committing the lesser. Conversely, if the lesser offense contains an element that is not part of the greater offense, the lesser cannot be included in the greater.
The factual test requires the court to determine whether there is a sufficient factual basis in the record for submitting the included offense.
State v. Lampman, 345 N.W.2d 142, 143 (Iowa 1984) (citations omitted); see also State v. Mateer, 383 N.W.2d 533, 536 (Iowa 1986). Both tests must be satisfied before the defendant is entitled to an instruction on each lesser included offense. Mateer, 383 N.W.2d at 536.
In State v. Powers, we held that assault as defined in Iowa Code section 708.1 is a lesser included offense of the crime of attempt to commit murder. 278 N.W.2d 26, 28 (Iowa 1979). The legal test is therefore satisfied. The only issue concerns the factual test.
In State v. Morgan, we provided a formula for determining whether the factual test has been met:
In the included offense setting the courts apply a principle that when the major offense consists of elements A, B, and C, the lesser offense consists of elements B and C, and the record does not contain substantial evidence from some quarter controverting element A, the State's case stands or falls on the major offense.
322 N.W.2d 68, 69-70 (Iowa 1982) (emphasis in original). See also State v. Ware, 338 N.W.2d 707, 716 (Iowa 1983); State v. Harlow, 325 N.W.2d 90, 91 (Iowa 1982). In the present case a specific intent to kill, because it raises assault to attempted murder, is the element A mentioned in Morgan. See Iowa Code §§ 708.1, 707.11. Our task then is to examine the record to determine whether there is substantial evidence controverting the intent to kill.
Defendant took the position at trial that he was never there and offered no evidence to suggest the victim was merely threatened. In refusing to instruct the jury on any lesser included offenses, the trial court noted that defendant's alibi defense created an "all or nothing" case on the issue of whether defendant committed attempted murder. The trial court said:

*300 There is no evidence ... from which a jury could find that a dangerous weapon or a firearm was pointed at the victim without anything more. The evidence is either that a weapon was fired or it never happened.
In Morgan the prosecuting witness testified that the defendant and another person attacked him and took his billfold. Although another prosecution witness also identified him, Morgan testified he had never seen the prosecuting witness until trial and did not remember the incident. Morgan's mother offered alibi testimony. The trial court submitted the elements of robbery based on assault but refused Morgan's request to submit assault as an included offense. We affirmed, noting that "[t]he present record does not contain substantial evidence controverting any of the elements which elevate this crime from assault to robbery." 322 N.W.2d at 71.
We have applied the same rationale in a number of other cases. See, e.g., State v. Hutchison, 341 N.W.2d 33, 42 (Iowa 1983) (defendant denied involvement in crime; court held instruction on lesser included offense not necessary); Ware, 338 N.W.2d at 716 (defendant's "principal factual defense" was alibi; defendant not entitled to instruction on lesser included offense); Harlow, 325 N.W.2d at 91 (defendant denied any participation in criminal act; no factual basis for submitting lesser offense).
Defendants in cases where submission of the lesser offenses was required were able to point to evidence which supported a version of facts making up the elements of the included offense. See, e.g., State v. Johnson, 328 N.W.2d 918, 920 (Iowa 1983) (where court found "ample evidence" of assault, trial court erred in refusing to submit assault as lesser included offense in robbery case); State v. Wales, 325 N.W.2d 87, 89 (Iowa 1982) (where burglary was alleged to have been committed in either of two ways, only one of which included criminal trespass as a lesser included offense, and evidence was sufficient to support a finding on either alternative, defendant entitled to submission of lesser included offense); State v. Sangster, 299 N.W.2d 661, 664 (Iowa 1980) (in second-degree burglary case, "[u]nder the evidence ... a rational jury could find the defendant guilty of criminal trespass. [T]he jury might find a failure of proof on the intent necessary for burglary but sufficient proof to establish the intent and other elements of criminal trespass.").
The evidence here, or more accurately the lack of it, puts this case within the ambit of our holdings in Morgan, Hutchison, and Harlow, and outside the Johnson, Wales, and Sangster holdings. There are only two versions of what happened. Defendant and his witnesses say he was not there. The State's evidence, including that of threats, points only to the major offense. There was simply no evidence controverting defendant's intent to kill. No one, not even defendant, offered testimony even hinting the shot was merely a plan to threaten or frighten Dawson. No evidence supports defendant's present contention that "the jury could rationally reject the State's theory of intent to kill and thereby reject the greater offense of attempted murder in favor of the legally included offense of assault, simple or aggravated." It was not error to refuse to submit the lesser included offenses.
II. We do find merit in defendant's other assignment, a contention that he should not have received a mandatory minimum sentence under Iowa Code section 902.7. That section provides in substance that a person who uses a firearm while participating in a forcible felony will, if convicted, receive a mandatory minimum sentence of five years.
Iowa rule of criminal procedure 6(6) provides:
Allegations of use of a firearm. If the offense charged is one for which the defendant, if convicted, will be subject by reason of the Code to a minimum sentence because of use of a firearm, the allegation of such use, if any, shall be contained in the indictment. If use of a firearm is alleged as provided by this rule, and if the allegation is supported by *301 the evidence, the court shall submit to the jury a special interrogatory concerning this matter, as provided in R.Cr.P. 21(2).
The trial information in this case contained no allegation of firearm possession. There was no application to amend the information to add such an allegation. See State v. Berney, 378 N.W.2d 915, 918-19 (Iowa 1985). Defendant argues that, because the trial information failed to allege firearm possession, the trial court erred in imposing a mandatory five-year sentence.
The State first resists the assignment by pointing out that defendant did not object to the application of section 902.7 at the time of sentencing and did not file a post-trial motion to correct any error. The court of appeals agreed with the State that error was not preserved and did not reach the merits of the assignment.
It is generally true that "[m]atters not raised in the trial court or in a post-trial motion will not be considered for the first time on appeal." State v. Morehouse, 316 N.W.2d 884, 886 (Iowa 1982). This general rule, however, does not serve to justify illegal sentences. State v. Young, 292 N.W.2d 432, 435 (Iowa 1980); see also State v. Ohnmacht, 342 N.W.2d 838, 843 (Iowa 1983) ("Void sentences are not subject to the usual concepts of waiver, whether from a failure to seek review or other omissions of error preservation."); State v. Wilson, 294 N.W.2d 824, 825-26 (Iowa 1980).
It was not necessary for defendant to either object to the sentence or raise the point by way of a post-trial motion. Error was not waived and we accordingly address the merits of the assignment.
III. It is not important that this case involved a county attorney's information, rather than a grand jury indictment. According to Iowa rule of criminal procedure 5(5), "`indictment' embraces the trial information, and all provisions of law applying to prosecutions on indictments apply also to informations, except where otherwise provided for by statute or in these rules, or when the context requires otherwise." See also State v. Williams, 193 N.W.2d 529, 530 (Iowa 1972) ("A county attorney's information shall be considered and construed in the same manner as an indictment.").
The State is correct in next arguing that defendant was obviously aware that use of a firearm was a contention of the prosecution. But this knowledge does not excuse the State's wholesale and continued failure to comply with rule 6(6). As mentioned, the use of a firearm was not alleged and the jury was not given the special interrogatory demanded by the rule.
Court rules are subject to rules of statutory construction. See Committee on Professional Ethics v. Shaffer, 230 N.W.2d 1, 2 (Iowa 1975). A cardinal rule of construction is that "[u]nless the context otherwise indicates the use of the word `shall' ... indicates a mandatory intent." 1A Sutherland, Statutes and Statutory Construction § 25.04, at 445 (Sands 4th ed. 1985). We applied this familiar rule in a number of cases. See, e.g., Consolidated Freight-ways Corp. of Delaware v. Nicholas, 258 Iowa 115, 121, 137 N.W.2d 900, 904 (1965). The rule has now been codified. Iowa Code § 4.1(36)(a) ("The word `shall' imposes a duty.").
If rule 6(6) is to have any meaning compliance must be mandatory. Having failed to comply with that rule the State is in no position to exact the mandatory sentence under the statute. The judgment of defendant's guilt is affirmed but the sentence imposed against him is vacated. The case is remanded for further proceedings in conformance with this opinion.
DECISION OF COURT OF APPEALS VACATED; AFFIRMED IN PART, REVERSED IN PART AND REMANDED.
All Justices concur except CARTER, J., who concurs specially.
CARTER, Justice (concurring specially).
I concur in the result, but my reasons for determining that there was no error in failing to submit lesser included offenses *302 are quite different from those stated in the opinion of the court.
I disagree with those decisions which hold that a defendant who presents an alibi defense may not also request that lesser included offenses meeting the statutory test be submitted to the jury. Notwithstanding the alibi defense, the State is required to prove all elements of the crime beyond a reasonable doubt including those elements of the greater offense which are dissimilar from the elements of the lesser offense. There is no reason either legally or logically why a jury in such cases may not reject the defendant's alibi theory, reject the State's evidence with respect to the dissimilar elements, but accept the State's evidence as to the common elements. Anytime that a jury is legally and logically free to do this, the lesser included offenses should be submitted.
I find no error in the present case, however, because in spite of the contrary suggestion in State v. Powers, 278 N.W.2d 26, 28 (Iowa 1979), I do not believe that, under the revised criminal code, the offenses of aggravated assault or simple assault meet the statutory test of offenses necessarily included in a charge of attempted murder as defined in Iowa Code section 707.11 (1983).
