]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Accept existential variables as record shorthand fields 09/409/1
authorHannu Niemistö <hannu.niemisto@iki.fi>
Mon, 10 Apr 2017 21:27:16 +0000 (00:27 +0300)
committerHannu Niemistö <hannu.niemisto@iki.fi>
Mon, 10 Apr 2017 21:27:16 +0000 (00:27 +0300)
Change-Id: I2d4ca35f26ba80795696b357f81d778420f40d51

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERecord.java

index 6ef9e9e72b4f69ef878e244484edc97880219cf1..a41c0f042d46034e782ec06b78888bfe146cf7c9 100644 (file)
@@ -54,11 +54,14 @@ public class ERecord extends ASTExpression {
         THashMap<String,FieldAssignment> recordMap = new THashMap<String,FieldAssignment>(fields.length);
         for(FieldAssignment field : fields) {
             if(field.value == null) {
+               String actualName = field.name;
+               if(actualName.charAt(0) == '?')
+                       actualName = actualName.substring(1);
                 String bestMatch = null;
                 int bestMatchLength = 0;
                 for(int i=0;i<fieldNames.length;++i) {
                     String fieldName = fieldNames[i];
-                    if(field.name.startsWith(fieldName) && fieldName.length() > bestMatchLength) {
+                    if(actualName.startsWith(fieldName) && fieldName.length() > bestMatchLength) {
                         bestMatch = fieldName;
                         bestMatchLength = fieldName.length();
                     }