Giter Club home page Giter Club logo

Comments (4)

pd93 avatar pd93 commented on September 27, 2024

This is behaving as intended. Since Task now supports any scalar variable type, if you give it a number, it will be interpreted as one (rather than the previous behaviour which automatically converted it to a string). Since the number you used far exceeds the maximum signed and unsigned 64 bit integer size, it is converted to a float approximation instead and when printed it will be displayed using scientific notation.

If you want your variable to be a string then you should always wrap it with quotes and it will be interpreted as expected:

  long-number:
    desc: Print a long number variable
    vars:
      LONG_NUMBER: "123456789012345678901234567890"
    cmds:
      - echo "{{.LONG_NUMBER}}"

from task.

manzamor-cs avatar manzamor-cs commented on September 27, 2024

I figured this might be the intended behavior and included the bit about the quotes after the example I provided. For future reference, should I assume minor version bumps could introduce breaking changes?

from task.

pd93 avatar pd93 commented on September 27, 2024

We don't (intentionally) make breaking changes in minor/patch versions. We follow SemVer rules for our CLI binary (Though it's worth remembering that the Golang package API does not share this compatibility guarantee). This is one of the reasons why we have experiment flags (for testing breaking changes to be made in future major releases).

I understand that this release made some Taskfiles behave differently. However, I would argue that this is still not considered to be a breaking change since it only changes the behaviour of incorrectly formatted YAML files. If anything, I would consider the previous behaviour to be buggy and we should have been erroring if we detected non-string variables.

The fact that in prior versions, you could define a YAML boolean and then not use {{if .BOOL_VAR}} when templating was not intuitive at all. Likewise, defining a YAML number without quotes implies that you should be able to do {{index (list 1 2 3) .NUM_VAR}}. However, this would have errored with cannot index slice/array with type string. In 3.37.0+ both these scenarios work as expected.

Sidenote: One of my least favourite things about YAML is that it lets you define strings without using quotes. It leads to a lot of problems/misunderstandings. Especially given that y, n, yes, no, on, off, true and false are all parsed as bools depending on the parser and YAML version you're using. It's just messy and should be avoided at all costs. There is plenty of discussion on this topic on StackOverflow.

One thing is for sure though. If you want a string containing numeric-only characters - you need to quote it.

from task.

manzamor-cs avatar manzamor-cs commented on September 27, 2024

I understand what you mean about the previous behavior being considered a bug. I guess whether this is considered a "breaking change" is open to interpretation, but I can definitely see your point. Thanks for the explanation! 👍🏻

from task.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.