From 6d27277ef66da9fb2edf01c5362cc34a6564776a Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 22 Jan 2017 13:27:22 -0800 Subject: [PATCH 1/5] Update documentation for 1.12.3. --- documentation/sections/changelog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/documentation/sections/changelog.md b/documentation/sections/changelog.md index 8a2e168f59..8581a89292 100644 --- a/documentation/sections/changelog.md +++ b/documentation/sections/changelog.md @@ -1,5 +1,11 @@ ## Change Log +``` +releaseHeader('2017-01-22', '1.12.3', '1.12.2') +``` + +* CoffeeScript’s patched `Error.prepareStackTrace` has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2. + ``` releaseHeader('2016-12-16', '1.12.2', '1.12.1') ``` From 729127735b65f3c2d263ff673238586dd8abb7d3 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 22 Jan 2017 13:28:08 -0800 Subject: [PATCH 2/5] Bump version --- lib/coffee-script/browser.js | 2 +- lib/coffee-script/cake.js | 2 +- lib/coffee-script/coffee-script.js | 2 +- lib/coffee-script/command.js | 2 +- lib/coffee-script/grammar.js | 2 +- lib/coffee-script/helpers.js | 2 +- lib/coffee-script/index.js | 2 +- lib/coffee-script/lexer.js | 2 +- lib/coffee-script/nodes.js | 2 +- lib/coffee-script/optparse.js | 2 +- lib/coffee-script/parser.js | 2 +- lib/coffee-script/register.js | 2 +- lib/coffee-script/repl.js | 2 +- lib/coffee-script/rewriter.js | 2 +- lib/coffee-script/scope.js | 2 +- lib/coffee-script/sourcemap.js | 2 +- package.json | 4 ++-- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/coffee-script/browser.js b/lib/coffee-script/browser.js index 5f8f2b247c..5840a33e9b 100644 --- a/lib/coffee-script/browser.js +++ b/lib/coffee-script/browser.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var CoffeeScript, compile, runScripts, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; diff --git a/lib/coffee-script/cake.js b/lib/coffee-script/cake.js index 5593a0a86c..f513d853c5 100644 --- a/lib/coffee-script/cake.js +++ b/lib/coffee-script/cake.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks; diff --git a/lib/coffee-script/coffee-script.js b/lib/coffee-script/coffee-script.js index 76914cdecd..f482620d30 100644 --- a/lib/coffee-script/coffee-script.js +++ b/lib/coffee-script/coffee-script.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var Lexer, SourceMap, base64encode, compile, ext, fn1, formatSourcePosition, fs, getSourceMap, helpers, i, len, lexer, packageJson, parser, path, ref, sourceMaps, sources, vm, withPrettyErrors, hasProp = {}.hasOwnProperty; diff --git a/lib/coffee-script/command.js b/lib/coffee-script/command.js index 8e2706b6b7..795eaa961c 100644 --- a/lib/coffee-script/command.js +++ b/lib/coffee-script/command.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, makePrelude, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; diff --git a/lib/coffee-script/grammar.js b/lib/coffee-script/grammar.js index 396d46881b..88da72aa27 100644 --- a/lib/coffee-script/grammar.js +++ b/lib/coffee-script/grammar.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; diff --git a/lib/coffee-script/helpers.js b/lib/coffee-script/helpers.js index 02a44d11dc..cb7f41be87 100644 --- a/lib/coffee-script/helpers.js +++ b/lib/coffee-script/helpers.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString; diff --git a/lib/coffee-script/index.js b/lib/coffee-script/index.js index 39a445f0ff..d12469e3df 100644 --- a/lib/coffee-script/index.js +++ b/lib/coffee-script/index.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var key, ref, val; diff --git a/lib/coffee-script/lexer.js b/lib/coffee-script/lexer.js index e05e724677..c996c43c7c 100644 --- a/lib/coffee-script/lexer.js +++ b/lib/coffee-script/lexer.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, HERE_JSTOKEN, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVALID_ESCAPE, INVERSES, JSTOKEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, isForFrom, isUnassignable, key, locationDataToString, ref, ref1, repeat, starts, throwSyntaxError, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index ed7e609055..7d8b50c4e0 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var Access, Arr, Assign, Base, Block, BooleanLiteral, Call, Class, Code, CodeFragment, Comment, Existence, Expansion, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, ExportSpecifier, ExportSpecifierList, Extends, For, IdentifierLiteral, If, ImportClause, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, ImportSpecifierList, In, Index, InfinityLiteral, JS_FORBIDDEN, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, ModuleDeclaration, ModuleSpecifier, ModuleSpecifierList, NEGATE, NO, NaNLiteral, NullLiteral, NumberLiteral, Obj, Op, Param, Parens, PassthroughLiteral, PropertyName, Range, RegexLiteral, RegexWithInterpolations, Return, SIMPLENUM, Scope, Slice, Splat, StatementLiteral, StringLiteral, StringWithInterpolations, SuperCall, Switch, TAB, THIS, TaggedTemplateCall, ThisLiteral, Throw, Try, UTILITIES, UndefinedLiteral, Value, While, YES, YieldReturn, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isComplexOrAssignable, isLiteralArguments, isLiteralThis, isUnassignable, locationDataToString, merge, multident, ref1, ref2, some, starts, throwSyntaxError, unfoldSoak, utility, extend1 = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, diff --git a/lib/coffee-script/optparse.js b/lib/coffee-script/optparse.js index 75153891b7..b0ea83c89f 100644 --- a/lib/coffee-script/optparse.js +++ b/lib/coffee-script/optparse.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat; diff --git a/lib/coffee-script/parser.js b/lib/coffee-script/parser.js index 887b592d55..2d13baa694 100755 --- a/lib/coffee-script/parser.js +++ b/lib/coffee-script/parser.js @@ -873,7 +873,7 @@ exports.main = function commonjsMain(args) { console.log('Usage: '+args[0]+' FILE'); process.exit(1); } - var source = null; + var source = ''; var fs = require('fs'); if (typeof fs !== 'undefined' && fs !== null) source = fs.readFileSync(require('path').normalize(args[1]), "utf8"); diff --git a/lib/coffee-script/register.js b/lib/coffee-script/register.js index d17cffc230..b2ca5941b6 100644 --- a/lib/coffee-script/register.js +++ b/lib/coffee-script/register.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref; diff --git a/lib/coffee-script/repl.js b/lib/coffee-script/repl.js index cab700f471..f6ee94c242 100644 --- a/lib/coffee-script/repl.js +++ b/lib/coffee-script/repl.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, runInContext, updateSyntaxError, vm; diff --git a/lib/coffee-script/rewriter.js b/lib/coffee-script/rewriter.js index 1d8f8ade1b..8021202c72 100644 --- a/lib/coffee-script/rewriter.js +++ b/lib/coffee-script/rewriter.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, k, left, len, ref, rite, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, diff --git a/lib/coffee-script/scope.js b/lib/coffee-script/scope.js index ad36841672..cd8939fd86 100644 --- a/lib/coffee-script/scope.js +++ b/lib/coffee-script/scope.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var Scope, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; diff --git a/lib/coffee-script/sourcemap.js b/lib/coffee-script/sourcemap.js index 0e178d5e1e..ca396dfdea 100644 --- a/lib/coffee-script/sourcemap.js +++ b/lib/coffee-script/sourcemap.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.2 +// Generated by CoffeeScript 1.12.3 (function() { var LineMap, SourceMap; diff --git a/package.json b/package.json index 5de2c46a52..ca21e6756f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "compiler" ], "author": "Jeremy Ashkenas", - "version": "1.12.2", + "version": "1.12.3", "license": "MIT", "engines": { "node": ">=0.8.0" @@ -40,7 +40,7 @@ }, "devDependencies": { "docco": "~0.7.0", - "google-closure-compiler-js": "^20161201.0.0", + "google-closure-compiler-js": "^20161201.0.1", "highlight.js": "~9.9.0", "jison": ">=0.4.17", "marked": "^0.3.6", From 45d0a7d01f13357f614f4cde2657b397a796d2c3 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 22 Jan 2017 13:30:04 -0800 Subject: [PATCH 3/5] Update browser compiler for 1.12.3 --- docs/v1/browser-compiler/coffee-script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/v1/browser-compiler/coffee-script.js b/docs/v1/browser-compiler/coffee-script.js index 207635622a..652ce86e12 100644 --- a/docs/v1/browser-compiler/coffee-script.js +++ b/docs/v1/browser-compiler/coffee-script.js @@ -1,5 +1,5 @@ /** - * CoffeeScript Compiler v1.12.2 + * CoffeeScript Compiler v1.12.3 * http://coffeescript.org * * Copyright 2011, Jeremy Ashkenas @@ -13,8 +13,8 @@ $jscomp.polyfill("Array.prototype.find",function(u){return u?u:function(u,qa){re $jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var u=$jscomp.global.Symbol.iterator;u||(u=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[u]&&$jscomp.defineProperty(Array.prototype,u,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}}; $jscomp.arrayIterator=function(u){var ya=0;return $jscomp.iteratorPrototype(function(){return ya>>=1,a+=a;return f};g.compact=function(a){var f,c,g,q;q=[];f=0;for(g=a.length;f Date: Sun, 22 Jan 2017 13:30:38 -0800 Subject: [PATCH 4/5] Update generated docs for 1.12.3 --- docs/v1/annotated-source/coffee-script.html | 323 ++++++++++++++++---- docs/v1/annotated-source/nodes.html | 7 +- docs/v1/index.html | 21 +- 3 files changed, 284 insertions(+), 67 deletions(-) diff --git a/docs/v1/annotated-source/coffee-script.html b/docs/v1/annotated-source/coffee-script.html index 9c498ae5c0..99a4d22ab0 100644 --- a/docs/v1/annotated-source/coffee-script.html +++ b/docs/v1/annotated-source/coffee-script.html @@ -249,34 +249,88 @@

coffee-script.coffee

+

For each compiled file, save its source in memory in case we need to +recompile it later. We might need to recompile if the first compilation +didn’t create a source map (faster) but something went wrong and we need +a stack trace. Assuming that most of the time, code isn’t throwing +exceptions, it’s probably more efficient to compile twice only when we +need a stack trace, rather than always generating a source map even when +it’s not likely to be used. Save in form of filename: (source)

+ + + +
sources = {}
+ + + + +
  • +
    + +
    + +
    +

    Also save source maps if generated, in form of filename: (source map).

    + +
    + +
    sourceMaps = {}
    + +
  • + + +
  • +
    + +
    + +

    Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.

    -

    If options.sourceMap is specified, then options.filename must also be specified. All -options that can be passed to SourceMap#generate may also be passed here.

    +

    If options.sourceMap is specified, then options.filename must also be +specified. All options that can be passed to SourceMap#generate may also +be passed here.

    This returns a javascript string, unless options.sourceMap is passed, in which case this returns a {js, v3SourceMap, sourceMap} -object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic -lookups.

    +object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for +doing programmatic lookups.

    exports.compile = compile = withPrettyErrors (code, options) ->
       {merge, extend} = helpers
    -  options = extend {}, options
    -  generateSourceMap = options.sourceMap or options.inlineMap
    +  options = extend {}, options
    + +
  • + + +
  • +
    + +
    + +
    +

    Always generate a source map if no filename is passed in, since without a +a filename we have no way to retrieve this source later in the event that +we need to recompile it to get a source map for prepareStackTrace.

    - if generateSourceMap - map = new SourceMap +
    + +
      generateSourceMap = options.sourceMap or options.inlineMap or not options.filename?
    +  filename = options.filename or '<anonymous>'
    +
    +  sources[filename] = code
    +  map = new SourceMap if generateSourceMap
     
       tokens = lexer.tokenize code, options
  • -
  • +
  • - +

    Pass a list of referenced variables, so that generated variables won’t get the same name.

    @@ -290,13 +344,13 @@

    coffee-script.coffee

  • -
  • +
  • - +
    -

    Check for import or export; if found, force bare mode

    +

    Check for import or export; if found, force bare mode.

    @@ -318,13 +372,13 @@

    coffee-script.coffee

  • -
  • +
  • - +
    -

    Update the sourcemap with data from each fragment

    +

    Update the sourcemap with data from each fragment.

    @@ -333,11 +387,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Do not include empty, whitespace, or semicolon-only fragments.

    @@ -358,11 +412,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Copy the code from each fragment into the final JavaScript.

    @@ -376,6 +430,7 @@

    coffee-script.coffee

    if generateSourceMap v3SourceMap = map.generate(options, code) + sourceMaps[filename] = map if options.inlineMap encoded = base64encode JSON.stringify v3SourceMap @@ -395,11 +450,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Tokenize a string of CoffeeScript code, and return the array of tokens.

    @@ -411,11 +466,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Parse a string of CoffeeScript code or an array of lexed tokens, and return the AST. You can then compile it by calling .compile() on the root, @@ -432,11 +487,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Compile and execute a string of CoffeeScript (on the server), correctly setting __filename, __dirname, and relative require().

    @@ -449,27 +504,27 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Set the filename.

      mainModule.filename = process.argv[1] =
    -    if options.filename then fs.realpathSync(options.filename) else '.'
    + if options.filename then fs.realpathSync(options.filename) else '<anonymous>'
  • -
  • +
  • - +

    Clear the module cache.

    @@ -480,17 +535,17 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Assign paths for node_modules loading

    -
      dir = if options.filename
    +            
      dir = if options.filename?
         path.dirname fs.realpathSync options.filename
       else
         fs.realpathSync '.'
    @@ -499,11 +554,11 @@ 

    coffee-script.coffee

  • -
  • +
  • - +

    Compile.

    @@ -518,11 +573,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Compile and evaluate a string of CoffeeScript (in a Node.js-like environment). The CoffeeScript REPL uses this to run the input.

    @@ -552,11 +607,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    define module/require only if they chose not to specify their own

    @@ -573,11 +628,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    use the same hack node currently uses for their own REPL

    @@ -599,11 +654,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Throw error with deprecation warning when depending upon implicit require.extensions registration

    @@ -617,8 +672,22 @@

    coffee-script.coffee

    """ exports._compileFile = (filename, sourceMap = no, inlineMap = no) -> - raw = fs.readFileSync filename, 'utf8' - stripped = if raw.charCodeAt(0) is 0xFEFF then raw.substring 1 else raw + raw = fs.readFileSync filename, 'utf8'
    + +
  • + + +
  • +
    + +
    + +
    +

    Strip the Unicode byte order mark, if this file begins with one.

    + +
    + +
      stripped = if raw.charCodeAt(0) is 0xFEFF then raw.substring 1 else raw
     
       try
         answer = compile stripped, {
    @@ -631,11 +700,11 @@ 

    coffee-script.coffee

  • -
  • +
  • - +

    As the filename and code of a dynamically loaded file will be different from the original file compiled with CoffeeScript.run, add that @@ -650,11 +719,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Instantiate a Lexer for our use here.

    @@ -665,11 +734,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    The real Lexer produces a generic stream of tokens. This object provides a thin wrapper around it, compatible with the Jison API. We can then pass it @@ -697,11 +766,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Make all the AST nodes visible to the parser.

    @@ -712,11 +781,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Override Jison’s default error handling function.

    @@ -727,11 +796,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    Disregard Jison’s message, it contains redundant line number information. Disregard the token, we take its value directly from the lexer in case @@ -755,11 +824,11 @@

    coffee-script.coffee

  • -
  • +
  • - +

    The second argument has a loc property, which should have the location data for this token. Unfortunately, Jison seems to send an outdated loc @@ -772,6 +841,140 @@

    coffee-script.coffee

  • + +
  • +
    + +
    + +
    +

    Based on http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js +Modified to handle sourceMap

    + +
    + +
    formatSourcePosition = (frame, getSourceMapping) ->
    +  filename = undefined
    +  fileLocation = ''
    +
    +  if frame.isNative()
    +    fileLocation = "native"
    +  else
    +    if frame.isEval()
    +      filename = frame.getScriptNameOrSourceURL()
    +      fileLocation = "#{frame.getEvalOrigin()}, " unless filename
    +    else
    +      filename = frame.getFileName()
    +
    +    filename or= "<anonymous>"
    +
    +    line = frame.getLineNumber()
    +    column = frame.getColumnNumber()
    + +
  • + + +
  • +
    + +
    + +
    +

    Check for a sourceMap position

    + +
    + +
        source = getSourceMapping filename, line, column
    +    fileLocation =
    +      if source
    +        "#{filename}:#{source[0]}:#{source[1]}"
    +      else
    +        "#{filename}:#{line}:#{column}"
    +
    +  functionName = frame.getFunctionName()
    +  isConstructor = frame.isConstructor()
    +  isMethodCall = not (frame.isToplevel() or isConstructor)
    +
    +  if isMethodCall
    +    methodName = frame.getMethodName()
    +    typeName = frame.getTypeName()
    +
    +    if functionName
    +      tp = as = ''
    +      if typeName and functionName.indexOf typeName
    +        tp = "#{typeName}."
    +      if methodName and functionName.indexOf(".#{methodName}") isnt functionName.length - methodName.length - 1
    +        as = " [as #{methodName}]"
    +
    +      "#{tp}#{functionName}#{as} (#{fileLocation})"
    +    else
    +      "#{typeName}.#{methodName or '<anonymous>'} (#{fileLocation})"
    +  else if isConstructor
    +    "new #{functionName or '<anonymous>'} (#{fileLocation})"
    +  else if functionName
    +    "#{functionName} (#{fileLocation})"
    +  else
    +    fileLocation
    +
    +getSourceMap = (filename) ->
    +  if sourceMaps[filename]?
    +    sourceMaps[filename]
    + +
  • + + +
  • +
    + +
    + +
    +

    CoffeeScript compiled in a browser may get compiled with options.filename +of <anonymous>, but the browser may request the stack trace with the +filename of the script file.

    + +
    + +
      else if sourceMaps['<anonymous>']?
    +    sourceMaps['<anonymous>']
    +  else if sources[filename]?
    +    answer = compile sources[filename],
    +      filename: filename
    +      sourceMap: yes
    +    answer.sourceMap
    +  else
    +    null
    + +
  • + + +
  • +
    + +
    + +
    +

    Based on michaelficarra/CoffeeScriptRedux +NodeJS / V8 have no support for transforming positions in stack traces using +sourceMap, so we must monkey-patch Error to display CoffeeScript source +positions.

    + +
    + +
    Error.prepareStackTrace = (err, stack) ->
    +  getSourceMapping = (filename, line, column) ->
    +    sourceMap = getSourceMap filename
    +    answer = sourceMap.sourceLocation [line - 1, column - 1] if sourceMap?
    +    if answer? then [answer[0] + 1, answer[1] + 1] else null
    +
    +  frames = for frame in stack
    +    break if frame.getFunction() is exports.run
    +    "    at #{formatSourcePosition frame, getSourceMapping}"
    +
    +  "#{err.toString()}\n#{frames.join '\n'}\n"
    + +
  • + diff --git a/docs/v1/annotated-source/nodes.html b/docs/v1/annotated-source/nodes.html index 8d1c78bcc9..2b60c5a455 100644 --- a/docs/v1/annotated-source/nodes.html +++ b/docs/v1/annotated-source/nodes.html @@ -4114,7 +4114,8 @@

    Op

    compileFloorDivision: (o) -> floor = new Value new IdentifierLiteral('Math'), [new Access new PropertyName 'floor'] - div = new Op '/', @first, @second + second = if @second.isComplex() then new Parens @second else @second + div = new Op '/', @first, second new Call(floor, [div]).compileToFragments o compileModulo: (o) -> @@ -4591,7 +4592,7 @@

    For

    @index.error 'cannot use index with for-from' if @from and @index source.ownTag.error "cannot use own with for-#{if @from then 'from' else 'in'}" if @own and not @object [@name, @index] = [@index, @name] if @object - @index.error 'index cannot be a pattern matching expression' if @index instanceof Value + @index.error 'index cannot be a pattern matching expression' if @index instanceof Value and not @index.isAssignable() @range = @source instanceof Value and @source.base instanceof Range and not @source.properties.length and not @from @pattern = @name instanceof Value @index.error 'indexes do not apply to range loops' if @range and @index @@ -4625,7 +4626,7 @@

    For

    name = @name and (@name.compile o, LEVEL_LIST) if not @pattern index = @index and (@index.compile o, LEVEL_LIST) scope.find(name) if name and not @pattern - scope.find(index) if index + scope.find(index) if index and @index not instanceof Value rvar = scope.freeVariable 'results' if @returns if @from ivar = scope.freeVariable 'x', single: true if @pattern diff --git a/docs/v1/index.html b/docs/v1/index.html index 83654de459..983dc44dc3 100644 --- a/docs/v1/index.html +++ b/docs/v1/index.html @@ -607,7 +607,7 @@

    CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

    The golden rule of CoffeeScript is: “It’s just JavaScript”. The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.

    The CoffeeScript compiler goes to great lengths to generate output JavaScript that runs in every JavaScript runtime, but there are exceptions. Use generator functions, for…from, or tagged template literals only if you know that your target runtimes can support them. If you use modules, you will need to use an additional tool to resolve them.

    -

    Latest Version: 1.12.2

    +

    Latest Version: 1.12.3

    npm install -g coffee-script
    @@ -1936,8 +1936,10 @@

    Destructuring Assignment

    Just like JavaScript (since ES2015), CoffeeS "Bellagio, Italy 22021" ] +{sculptor} = futurists + {poet: {name, address: [street, city]}} = futurists -

    var city, futurists, name, ref, ref1, street;
    +
    var city, futurists, name, ref, ref1, sculptor, street;
     
     futurists = {
       sculptor: "Umberto Boccioni",
    @@ -1948,8 +1950,10 @@ 

    Destructuring Assignment

    Just like JavaScript (since ES2015), CoffeeS } }; +sculptor = futurists.sculptor; + ref = futurists.poet, name = ref.name, (ref1 = ref.address, street = ref1[0], city = ref1[1]); -

    load
    load
    run: name + "-" + street

    Destructuring assignment can even be combined with splats.

    tag = "<impossible>"
    @@ -2603,7 +2609,14 @@ 

    Web Chat (IRC)

    Quick help and advice can usually be found in the Coff -

    Change Log

    +

    Change Log

    +

    + 1.12.3 + +

      +
    • CoffeeScript’s patched Error.prepareStackTrace has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2.
    • +
    +

    1.12.2 From b89dd043d3650a3901e09aa0e9aaf1ffd9efbdd0 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 22 Jan 2017 16:13:53 -0800 Subject: [PATCH 5/5] Add other 1.12.3 updates to changelog --- docs/v1/index.html | 2 ++ documentation/sections/changelog.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/v1/index.html b/docs/v1/index.html index 983dc44dc3..f6072d752f 100644 --- a/docs/v1/index.html +++ b/docs/v1/index.html @@ -2614,7 +2614,9 @@

    1.12.3

      +
    • @ values can now be used as indices in for expressions. This loosens the compilation of for expressions to allow the index variable to be an @ value, e.g. do @visit for @node, @index in nodes. Within @visit, the index of the current node (@node) would be available as @index.
    • CoffeeScript’s patched Error.prepareStackTrace has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2.
    • +
    • The //= operator’s output now wraps parentheses around the right operand, like the other assignment operators.

    diff --git a/documentation/sections/changelog.md b/documentation/sections/changelog.md index 8581a89292..9740032047 100644 --- a/documentation/sections/changelog.md +++ b/documentation/sections/changelog.md @@ -4,7 +4,9 @@ releaseHeader('2017-01-22', '1.12.3', '1.12.2') ``` +* `@` values can now be used as indices in `for` expressions. This loosens the compilation of `for` expressions to allow the index variable to be an `@` value, e.g. `do @visit for @node, @index in nodes`. Within `@visit`, the index of the current node (`@node`) would be available as `@index`. * CoffeeScript’s patched `Error.prepareStackTrace` has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2. +* The `//=` operator’s output now wraps parentheses around the right operand, like the other assignment operators. ``` releaseHeader('2016-12-16', '1.12.2', '1.12.1')