]> ocean-lang.org Git - ocean/commitdiff
oceani: fix parsing of error in struct field.
authorNeilBrown <neil@brown.name>
Sat, 18 Dec 2021 09:29:30 +0000 (20:29 +1100)
committerNeilBrown <neil@brown.name>
Sat, 18 Dec 2021 09:35:30 +0000 (20:35 +1100)
If there is an error - we violated our segments.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani-tests.mdc
csrc/oceani.mdc

index b613ffe484133dd040753b3fa27c129635c37839..e502822eca852eab30e7c320ddc9bb079c862282 100644 (file)
@@ -922,7 +922,7 @@ various places that `type_err()` are called.
 
        struct foo
                a: number
-               b:string = "hello"
+               b:string = "hello"; d:Boolean
 
        func main()
                c := "hello"
@@ -1033,10 +1033,12 @@ various places that `type_err()` are called.
                b:string
        struct foo
                c:number
+               x:[5]:string
 
 ###### output: type_err5
        .tmp.code:8:7: error: type already declared: foo
        .tmp.code:2:7: info: this is location of declartion: foo
+       .tmp.code:10:13: Syntax error in struct field: :
        .tmp.code:5:7: error: type has recursive definition: baz
        .tmp.code:2:7: error: type has recursive definition: foo
 
index 0778da21115f81acb7018fdd3bae8655e0af7428..2f3c9731e9ed703ad095a954855bd85cd43c20e7 100644 (file)
@@ -2969,10 +2969,17 @@ function will be needed.
        | SimpleFieldList EOL ${ $0 = $<SFL; }$
 
        FieldLines -> SimpleFieldList Newlines ${ $0 = $<SFL; }$
-       | FieldLines SimpleFieldList Newlines ${
-               $SFL->prev = $<FL;
-               $0 = $<SFL;
-       }$
+       | FieldLines SimpleFieldList Newlines ${ {
+               struct fieldlist *f = $<SFL;
+
+               if (f) {
+                       $0 = f;
+                       while (f->prev)
+                               f = f->prev;
+                       f->prev = $<FL;
+               } else
+                       $0 = $<FL;
+       } }$
 
        SimpleFieldList -> Field ${ $0 = $<F; }$
        | SimpleFieldList ; Field ${