@informalsystems/quint
Version:
Core tool for the Quint specification language
75 lines (72 loc) • 2.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.duplicatedRecordField = exports.undeclaredTypeParamsError = exports.tooManySpreadsError = exports.mapSyntaxError = exports.lowercaseTypeError = void 0;
function lowercaseTypeError(id, name, prefix) {
const original = [...prefix, name].join('::');
const newName = name[0].toUpperCase() + name.slice(1);
const replacement = [...prefix, newName].join('::');
return {
code: 'QNT007',
message: 'type names must start with an uppercase letter',
reference: id,
data: {
fix: {
kind: 'replace',
original: `type ${original}`,
replacement: `type ${replacement}`,
},
},
};
}
exports.lowercaseTypeError = lowercaseTypeError;
function mapSyntaxError(id, keyType, valueType) {
const original = `Map[${keyType}, ${valueType}]`;
const replacement = `${keyType} -> ${valueType}`;
return {
code: 'QNT015',
message: `Use '${replacement}' instead of '${original}' for map types`,
reference: id,
data: {
fix: {
kind: 'replace',
original,
replacement,
},
},
};
}
exports.mapSyntaxError = mapSyntaxError;
function tooManySpreadsError(id) {
return {
code: 'QNT012',
message: '... may be used once in { ...record, <fields> }',
reference: id,
data: {},
};
}
exports.tooManySpreadsError = tooManySpreadsError;
function undeclaredTypeParamsError(id, unboundTypeVariables) {
return {
code: 'QNT014',
message: `the type variables ${unboundTypeVariables.join(', ')} are unbound.
E.g., in
type T = List[a]
type variable 'a' is unbound. To fix it, write
type T[a] = List[a]`,
reference: id,
data: {},
};
}
exports.undeclaredTypeParamsError = undeclaredTypeParamsError;
function duplicatedRecordField(id, names) {
const joined = names.join(', ');
const plural = names.length > 1 ? 'Fields' : 'Field';
return {
code: 'QNT016',
message: `${plural} ${joined} cannot be defined more than once`,
reference: id,
data: {},
};
}
exports.duplicatedRecordField = duplicatedRecordField;
//# sourceMappingURL=parseErrors.js.map