diff --git a/.changeset/twenty-rocks-lie.md b/.changeset/twenty-rocks-lie.md new file mode 100644 index 0000000000..0fae66a4c4 --- /dev/null +++ b/.changeset/twenty-rocks-lie.md @@ -0,0 +1,5 @@ +--- +"@quri/squiggle-lang": patch +--- + +Bug fix: frWithTags should work for 0 value diff --git a/packages/squiggle-lang/__tests__/library/tag_test.ts b/packages/squiggle-lang/__tests__/library/tag_test.ts index 3bc210d164..e4640ca5ce 100644 --- a/packages/squiggle-lang/__tests__/library/tag_test.ts +++ b/packages/squiggle-lang/__tests__/library/tag_test.ts @@ -18,6 +18,7 @@ describe("Tags", () => { describe("format", () => { testEvalToBe("123 -> Tag.format('.2%') -> Tag.getFormat", '".2%"'); + testEvalToBe("0 -> Tag.format('.2%') -> Tag.getFormat", '".2%"'); }); describe("notebook", () => { diff --git a/packages/squiggle-lang/src/library/registry/frTypes.ts b/packages/squiggle-lang/src/library/registry/frTypes.ts index ca37858a76..3aee449373 100644 --- a/packages/squiggle-lang/src/library/registry/frTypes.ts +++ b/packages/squiggle-lang/src/library/registry/frTypes.ts @@ -174,7 +174,7 @@ export const frWithTags = ( unpack: (v) => { const unpackedItem = itemType.unpack(v); return ( - (unpackedItem && { + (unpackedItem !== undefined && { value: unpackedItem, tags: v.tags ?? new ValueTags({}), }) ||