dfinity / motoko

Simple high-level language for writing Internet Computer canisters
Apache License 2.0
500 stars 98 forks source link

Parser too liberal: No semicolon after imports required #2296

Open nomeata opened 3 years ago

nomeata commented 3 years ago
~/dfinity/motoko $ cat test.mo 
import Prim "mo:prim"
Prim.debugPrint("foo")
~/dfinity/motoko $ moc test.mo 
~/dfinity/motoko $ cat test.mo 
import Prim "mo:prim"
import Prim "mo:prim"
Prim.debugPrint("foo")
~/dfinity/motoko $ moc test.mo 
test.mo:2.1-2.7: syntax error [M0001], unexpected token 'import', expected one of token or <phrase> sequence:
  <eof>
  ; seplist(<imp>,<semicolon>)
  seplist(<dec>,<semicolon>) <eof>
rossberg commented 3 years ago

It's a known side-effect of the way the syntax is structured. We could forbid it, but that would require some duplication of productions. Didn't seem worth it at the time, but if anybody cares strongly, feel free to change.